apply patches

This commit is contained in:
openKylinBot 2022-05-14 03:14:50 +08:00
commit e22d7b9def
7 changed files with 91 additions and 63 deletions

View File

@ -1,3 +1,33 @@
_umount_points_list()
{
# List of characters to escape, shamelessly stolen from "scp" comp.
local escape_chars='[][(){}<>\",:;^&!$=?`|\\'\'' \t\f\n\r\v]'
# This is most odd, but we are adding artifically a space after the
# file name because, somehow, it enables proper escaping of dangerous
# characters, e.g. "|" -> "\|". Without space, it is possible to get
# either 0 "|" or 2 "\\|" backslashes, but 1 does not work. Also,
# sticking to sub() and gsub(), instead of gensub(), allows to be AWK
# implementation agnostic.
findmnt -lno TARGET | awk '{
if ($0 ~ "^"ENVIRON["HOME"]) {
homeless = $0
sub("^"ENVIRON["HOME"], "~", homeless)
gsub("'"$escape_chars"'", "\\\\&", homeless)
print homeless " "
}
if ($0 ~ "^"ENVIRON["PWD"]) {
reldir = $0
sub("^"ENVIRON["PWD"]"/?", "", reldir)
gsub("'"$escape_chars"'", "\\\\&", reldir)
print "./" reldir " "
print reldir " "
}
gsub("'"$escape_chars"'", "\\\\&")
print $0 " "
}'
}
_umount_module()
{
local cur prev OPTS
@ -48,28 +78,11 @@ _umount_module()
return 0
;;
esac
local oldifs=$IFS
IFS=$'\n'
COMPREPLY=( $( compgen -W "$(findmnt -lno TARGET | awk \
'{
if ($0 ~ ENVIRON["HOME"]) {
homeless = $0
homeless = gensub(ENVIRON["HOME"], "\\\\~", "g", homeless)
homeless = gensub(/(\s)/, "\\\\\\1", "g", homeless)
print homeless
}
if ($0 ~ ENVIRON["PWD"]) {
reldir = $0
reldir = gensub(ENVIRON["PWD"]"/", "", "g", reldir)
reldir = gensub(/(\s)/, "\\\\\\1", "g", reldir)
print "./" reldir
print reldir
}
gsub(/\s/, "\\\\&")
print $0
}'
)" -- "$cur" ) )
IFS=$oldifs
local IFS=$'\n'
COMPREPLY=( $( compgen -W '$( _umount_points_list )' -- "$cur" ) )
}
complete -F _umount_module umount
# counteract the artificial addition of " " in _gen_mount_points() by
# disabling spaces automatically appended to the end of the file name
# completion via "-o nospace".
complete -F _umount_module -o nospace umount

View File

@ -252,11 +252,12 @@ static int probe_xfs_log(blkid_probe pr,
if (!buf)
return errno ? -errno : 1;
if (memcmp(buf, "XFSB", 4) == 0)
return 1; /* this is regular XFS, ignore */
/* check the first 512 512-byte sectors */
for (i = 0; i < 512; i++) {
/* this is regular XFS (maybe with some sectors shift), ignore */
if (memcmp(&buf[i*512], "XFSB", 4) == 0)
return 1;
rhead = (struct xlog_rec_header *)&buf[i*512];
if (xlog_valid_rec_header(rhead)) {

View File

@ -795,6 +795,11 @@ static void sushell(struct passwd *pwd)
xsetenv("SHELL", "/bin/sh", 1);
execl("/bin/sh", profile ? "-sh" : "sh", NULL);
warn(_("failed to execute %s"), "/bin/sh");
/* Fall back to static shell */
setenv("SHELL", "/bin/static-sh", 1);
execl("/bin/static-sh", profile ? "-sh" : "sh", NULL);
warn(_("failed to execute %s"), "/bin/static-sh");
}
static void usage(void)
@ -978,7 +983,8 @@ int main(int argc, char **argv)
const char *passwd = pwd->pw_passwd;
const char *answer;
int doshell = 0;
int deny = !opt_e && locked_account_password(pwd->pw_passwd);
/* Ubuntu's root account is locked by default allow access without --force */
int deny = 0;
doprompt(passwd, con, deny);

View File

@ -1019,6 +1019,9 @@ static void device_to_scols(
DBG(DEV, ul_debugobj(dev, "add '%s' to scols", dev->name));
ON_DBG(DEV, if (ul_path_isopen_dirfd(dev->sysfs)) ul_debugobj(dev, " %s ---> is open!", dev->name));
if (!parent && dev->wholedisk)
parent = dev->wholedisk;
/* Do not print device more than one in --list mode */
if (!(lsblk->flags & LSBLK_TREE) && dev->is_printed)
return;

View File

@ -1,6 +1,7 @@
[Unit]
Description=Discard unused blocks on filesystems from /etc/fstab
Documentation=man:fstrim(8)
ConditionVirtualization=!container
[Service]
Type=oneshot

View File

@ -1,6 +1,7 @@
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim
ConditionVirtualization=!container
[Timer]
OnCalendar=weekly

View File

@ -638,28 +638,28 @@ display_time(struct timeval hwctime)
* tz.tz_minuteswest argument and sets PCIL (see below). At boot settimeofday(2)
* has one-shot access to this function as shown in the table below.
*
* +-------------------------------------------------------------------+
* | settimeofday(tv, tz) |
* |-------------------------------------------------------------------|
* | Arguments | System Time | PCIL | | warp_clock |
* | tv | tz | set | warped | set | firsttime | locked |
* |---------|---------|---------------|------|-----------|------------|
* | pointer | NULL | yes | no | no | 1 | no |
* | pointer | pointer | yes | no | no | 0 | yes |
* | NULL | ptr2utc | no | no | no | 0 | yes |
* | NULL | pointer | no | yes | yes | 0 | yes |
* +-------------------------------------------------------------------+
* +-------------------------------------------------------------------------+
* | settimeofday(tv, tz) |
* |-------------------------------------------------------------------------|
* | Arguments | System Time | TZ | PCIL | | warp_clock |
* | tv | tz | set | warped | set | set | firsttime | locked |
* |---------|---------|---------------|-----|------|-----------|------------|
* | pointer | NULL | yes | no | no | no | 1 | no |
* | NULL | ptr2utc | no | no | yes | no | 0 | yes |
* | NULL | pointer | no | yes | yes | yes | 0 | yes |
* +-------------------------------------------------------------------------+
* ptr2utc: tz.tz_minuteswest is zero (UTC).
* PCIL: persistent_clock_is_local, sets the "11 minute mode" timescale.
* firsttime: locks the warp_clock function (initialized to 1 at boot).
* Since glibc v2.31 settimeofday() will fail if both args are non NULL
*
* +---------------------------------------------------------------------------+
* | op | RTC scale | settimeofday calls |
* |---------|-----------|-----------------------------------------------------|
* | systz | Local | 1) warps system time*, sets PCIL* and kernel tz |
* | systz | UTC | 1st) locks warp_clock* 2nd) sets kernel tz |
* | hctosys | Local | 1st) sets PCIL* 2nd) sets system time and kernel tz |
* | hctosys | UTC | 1) sets system time and kernel tz |
* | hctosys | Local | 1st) sets PCIL* & kernel tz 2nd) sets system time |
* | hctosys | UTC | 1st) locks warp* 2nd) sets tz 3rd) sets system time |
* +---------------------------------------------------------------------------+
* * only on first call after boot
*/
@ -670,42 +670,45 @@ set_system_clock(const struct hwclock_control *ctl,
struct tm broken;
int minuteswest;
int rc = 0;
const struct timezone tz_utc = { 0 };
localtime_r(&newtime.tv_sec, &broken);
minuteswest = -get_gmtoff(&broken) / 60;
if (ctl->verbose) {
if (ctl->hctosys && !ctl->universal)
printf(_("Calling settimeofday(NULL, %d) to set "
"persistent_clock_is_local.\n"), minuteswest);
if (ctl->systz && ctl->universal)
if (ctl->universal) {
puts(_("Calling settimeofday(NULL, 0) "
"to lock the warp function."));
"to lock the warp_clock function."));
if (!( ctl->universal && !minuteswest ))
printf(_("Calling settimeofday(NULL, %d) "
"to set the kernel timezone.\n"),
minuteswest);
} else
printf(_("Calling settimeofday(NULL, %d) to warp "
"System time, set PCIL and the kernel tz.\n"),
minuteswest);
if (ctl->hctosys)
printf(_("Calling settimeofday(%ld.%06ld, %d)\n"),
newtime.tv_sec, newtime.tv_usec, minuteswest);
else {
printf(_("Calling settimeofday(NULL, %d) "), minuteswest);
if (ctl->universal)
puts(_("to set the kernel timezone."));
else
puts(_("to warp System time."));
}
printf(_("Calling settimeofday(%ld.%06ld, NULL) "
"to set the System time.\n"),
newtime.tv_sec, newtime.tv_usec);
}
if (!ctl->testing) {
const struct timezone tz_utc = { 0 };
const struct timezone tz = { minuteswest };
if (ctl->hctosys && !ctl->universal) /* set PCIL */
rc = settimeofday(NULL, &tz);
if (ctl->systz && ctl->universal) /* lock warp_clock */
/* If UTC RTC: lock warp_clock and PCIL */
if (ctl->universal)
rc = settimeofday(NULL, &tz_utc);
if (!rc && ctl->hctosys)
rc = settimeofday(&newtime, &tz);
else if (!rc)
/* Set kernel tz; if localtime RTC: warp_clock and set PCIL */
if (!rc && !( ctl->universal && !minuteswest ))
rc = settimeofday(NULL, &tz);
/* Set the System Clock */
if ((!rc || errno == ENOSYS) && ctl->hctosys)
rc = settimeofday(&newtime, NULL);
if (rc) {
warn(_("settimeofday() failed"));
return EXIT_FAILURE;
@ -1442,7 +1445,7 @@ hwclock_exit(const struct hwclock_control *ctl
if (ctl->hwaudit_on && !ctl->testing) {
audit_log_user_message(hwaudit_fd, AUDIT_USYS_CONFIG,
"op=change-system-time", NULL, NULL, NULL,
status);
status == EXIT_SUCCESS ? 1 : 0);
}
close(hwaudit_fd);
#endif