Rebase patches
This commit is contained in:
+2
-2
@@ -8,10 +8,10 @@ Bug: http://bugs.debian.org/1100563
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/useradd.c b/src/useradd.c
|
||||
index 5e4eb2c..dd12cdf 100644
|
||||
index dc65618..25a5920 100644
|
||||
--- a/src/useradd.c
|
||||
+++ b/src/useradd.c
|
||||
@@ -2430,14 +2430,21 @@ static void create_mail (void)
|
||||
@@ -2382,14 +2382,21 @@ static void create_mail (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ index eda1fef..38f2c68 100644
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
diff --git a/src/useradd.c b/src/useradd.c
|
||||
index ee52aaf..5e4eb2c 100644
|
||||
index 6e744b0..dc65618 100644
|
||||
--- a/src/useradd.c
|
||||
+++ b/src/useradd.c
|
||||
@@ -97,14 +97,14 @@ static const char Prog[] = "useradd";
|
||||
|
||||
@@ -12,7 +12,7 @@ Fixes: #166793
|
||||
3 files changed, 14 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/commonio.c b/lib/commonio.c
|
||||
index b7c9a2d..309efa0 100644
|
||||
index fc8ad7a..24a3230 100644
|
||||
--- a/lib/commonio.c
|
||||
+++ b/lib/commonio.c
|
||||
@@ -21,6 +21,7 @@
|
||||
@@ -23,7 +23,7 @@ index b7c9a2d..309efa0 100644
|
||||
|
||||
#include "alloc/malloc.h"
|
||||
#include "alloc/reallocf.h"
|
||||
@@ -953,12 +954,23 @@ int commonio_close (struct commonio_db *db)
|
||||
@@ -944,12 +945,23 @@ int commonio_close (struct commonio_db *db)
|
||||
if (errors)
|
||||
goto fail;
|
||||
} else {
|
||||
|
||||
@@ -57,10 +57,10 @@ index b485a5a..e20be0f 100644
|
||||
case 'h':
|
||||
usage (E_SUCCESS);
|
||||
diff --git a/src/useradd.c b/src/useradd.c
|
||||
index dd12cdf..ba0eb50 100644
|
||||
index 25a5920..7e9dbce 100644
|
||||
--- a/src/useradd.c
|
||||
+++ b/src/useradd.c
|
||||
@@ -895,7 +895,7 @@ static void usage (int status)
|
||||
@@ -879,7 +879,7 @@ static void usage (int status)
|
||||
"\n"
|
||||
"Options:\n"),
|
||||
Prog, Prog, Prog);
|
||||
@@ -69,7 +69,7 @@ index dd12cdf..ba0eb50 100644
|
||||
(void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n"
|
||||
" new account\n"), usageout);
|
||||
#ifdef WITH_BTRFS
|
||||
@@ -1241,6 +1241,9 @@ static void process_flags (int argc, char **argv)
|
||||
@@ -1202,6 +1202,9 @@ static void process_flags (int argc, char **argv)
|
||||
break;
|
||||
case 201:
|
||||
allow_bad_names = true;
|
||||
@@ -80,7 +80,7 @@ index dd12cdf..ba0eb50 100644
|
||||
case 'c':
|
||||
if (!VALID (optarg)) {
|
||||
diff --git a/src/usermod.c b/src/usermod.c
|
||||
index 7ea1a72..3e9e046 100644
|
||||
index 22113da..9030883 100644
|
||||
--- a/src/usermod.c
|
||||
+++ b/src/usermod.c
|
||||
@@ -383,7 +383,7 @@ usage (int status)
|
||||
@@ -92,7 +92,7 @@ index 7ea1a72..3e9e046 100644
|
||||
(void) fputs (_(" -c, --comment COMMENT new value of the GECOS field\n"), usageout);
|
||||
(void) fputs (_(" -d, --home HOME_DIR new home directory for the user account\n"), usageout);
|
||||
(void) fputs (_(" -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n"), usageout);
|
||||
@@ -1043,6 +1043,9 @@ process_flags(int argc, char **argv)
|
||||
@@ -1054,6 +1054,9 @@ process_flags(int argc, char **argv)
|
||||
break;
|
||||
case 'b':
|
||||
allow_bad_names = true;
|
||||
|
||||
@@ -9,7 +9,7 @@ Reported as https://github.com/shadow-maint/shadow/issues/1229
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 36c57d8..8a9c05a 100644
|
||||
index 571e20d..c9cd472 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -18,7 +18,7 @@ AC_SUBST([LIBSUBID_ABI], [libsubid_abi])
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
From: Chris Hofstaedtler <zeha@debian.org>
|
||||
Date: Mon, 24 Feb 2025 12:01:18 +0100
|
||||
Subject: configure.ac: be deterministic about passwd location
|
||||
|
||||
Improve reproducibility, without Build-Depend:ing on ourselves.
|
||||
|
||||
Forwarded: https://github.com/shadow-maint/shadow/issues/1224
|
||||
---
|
||||
configure.ac | 8 +-------
|
||||
1 file changed, 1 insertion(+), 7 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 8a9c05a..b7cc59c 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -115,13 +115,7 @@ AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$shadow_cv_logdir/lastlog",
|
||||
AC_DEFINE_UNQUOTED(FAILLOG_FILE, "$shadow_cv_logdir/faillog",
|
||||
[Path for faillog file.])
|
||||
|
||||
-AC_CACHE_CHECK([location of the passwd program], shadow_cv_passwd_dir,
|
||||
-[if test -f /usr/bin/passwd; then
|
||||
- shadow_cv_passwd_dir=/usr/bin
|
||||
-else
|
||||
- shadow_cv_passwd_dir=/bin
|
||||
-fi])
|
||||
-AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$shadow_cv_passwd_dir/passwd",
|
||||
+AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$exec_prefix/bin/passwd",
|
||||
[Path to passwd program.])
|
||||
|
||||
AC_ARG_ENABLE(shadowgrp,
|
||||
Vendored
+1
-8
@@ -9,11 +9,4 @@ debian/Define-LOGIN_NAME_MAX-on-HURD.patch
|
||||
debian/Stop-building-programs-we-do-not-install.patch
|
||||
debian/Warn-when-badname-and-variants-are-given.patch
|
||||
debian/configure.ac-align-exec_prefix-with-prefix.patch
|
||||
debian/configure.ac-be-deterministic-about-passwd-location.patch
|
||||
upstream/Revert-lib-src-Use-local-time-for-human-readable-dates.patch
|
||||
upstream/src-chfn.c-Partially-revert-lib-src-Use-strsep-3-instead-.patch
|
||||
upstream/src-chfn.c-Use-stpsep-instead-of-its-pattern.patch
|
||||
upstream/src-chfn.c-Add-local-variable-to-refer-to-the-separated-f.patch
|
||||
upstream/src-chfn.c-copy_field-Rename-local-variable.patch
|
||||
upstream/lib-getdate.y-Ignore-time-zone-information-and-use-UTC.patch
|
||||
Accept-usr-sbin-nologin-as-an-alternate-to-sbin-nologin.patch
|
||||
upstream/Accept-usr-sbin-nologin-as-an-alternate-to-sbin-nologin.patch
|
||||
|
||||
+6
-4
@@ -3,16 +3,18 @@ Date: Fri, 28 Mar 2025 12:12:13 +0100
|
||||
Subject: Accept /usr/sbin/nologin as an alternate to /sbin/nologin
|
||||
|
||||
Noticed by adduser's autopkgtests, thanks: Marc Haber
|
||||
|
||||
Link: https://github.com/shadow-maint/shadow/pull/1246
|
||||
---
|
||||
src/useradd.c | 1 +
|
||||
src/usermod.c | 1 +
|
||||
2 files changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/useradd.c b/src/useradd.c
|
||||
index ba0eb50..f654dd9 100644
|
||||
index 7e9dbce..0653d1d 100644
|
||||
--- a/src/useradd.c
|
||||
+++ b/src/useradd.c
|
||||
@@ -1419,6 +1419,7 @@ static void process_flags (int argc, char **argv)
|
||||
@@ -1380,6 +1380,7 @@ static void process_flags (int argc, char **argv)
|
||||
if (!streq(optarg, "")
|
||||
&& '*' != optarg[0]
|
||||
&& !streq(optarg, "/sbin/nologin")
|
||||
@@ -21,10 +23,10 @@ index ba0eb50..f654dd9 100644
|
||||
|| S_ISDIR(st.st_mode)
|
||||
|| access(optarg, X_OK) != 0)) {
|
||||
diff --git a/src/usermod.c b/src/usermod.c
|
||||
index 3e9e046..bfc7738 100644
|
||||
index 9030883..4156ce5 100644
|
||||
--- a/src/usermod.c
|
||||
+++ b/src/usermod.c
|
||||
@@ -1168,6 +1168,7 @@ process_flags(int argc, char **argv)
|
||||
@@ -1179,6 +1179,7 @@ process_flags(int argc, char **argv)
|
||||
if (!streq(optarg, "")
|
||||
&& '*' != optarg[0]
|
||||
&& !streq(optarg, "/sbin/nologin")
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Fri, 14 Feb 2025 21:25:01 +0100
|
||||
Subject: Revert "lib/, src/: Use local time for human-readable dates"
|
||||
|
||||
This reverts commit 3f5b4b56268269fefed55aa106f382037297d663.
|
||||
|
||||
The dates are stored as UTC, and are stored as a number of days since
|
||||
Epoch. We don't have enough precision to translate it into local time.
|
||||
Using local time has caused endless issues in users.
|
||||
|
||||
This patch is not enough for fixing this issue completely, since
|
||||
printing a date without time-zone information means that the date is a
|
||||
local date, but what we're printing is a UTC date. A future patch
|
||||
should add time-zone information to the date.
|
||||
|
||||
For now, let's revert this change that has caused so many issues.
|
||||
|
||||
Fixes: 3f5b4b562682 (2024-08-01; "lib/, src/: Use local time for human-readable dates")
|
||||
Link: <https://github.com/ansible/ansible/blob/devel/test/integration/targets/user/tasks/test_expires.yml#L2-L20>
|
||||
Link: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1095430>
|
||||
Link: <https://lists.iana.org/hyperkitty/list/tz@iana.org/message/ENE5IFV3GAH6WK22UJ6YU57D6TQINSP5/>
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/1202>
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/1057>
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/939>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1058>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1059#issuecomment-2309888519>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/952>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/942>
|
||||
Reported-by: Chris Hofstaedtler <zeha@debian.org>
|
||||
Reported-by: Gus Kenion <https://github.com/kenion>
|
||||
Reported-by: Alejandro Colomar <alx@kernel.org>
|
||||
Reported-by: Michael Vetter <jubalh@iodoru.org>
|
||||
Reported-by: Lee Garrett <lgarrett@rocketjump.eu>
|
||||
Cc: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Cc: Tim Parenti <tim@timtimeonline.com>
|
||||
Cc: Iker Pedrosa <ipedrosa@redhat.com>
|
||||
Cc: "Serge E. Hallyn" <serge@hallyn.com>
|
||||
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
lib/time/day_to_str.h | 2 +-
|
||||
src/chage.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/time/day_to_str.h b/lib/time/day_to_str.h
|
||||
index b70e989..fe3308d 100644
|
||||
--- a/lib/time/day_to_str.h
|
||||
+++ b/lib/time/day_to_str.h
|
||||
@@ -38,7 +38,7 @@ day_to_str(size_t size, char buf[size], long day)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (localtime_r(&date, &tm) == NULL) {
|
||||
+ if (gmtime_r(&date, &tm) == NULL) {
|
||||
strtcpy(buf, "future", size);
|
||||
return;
|
||||
}
|
||||
diff --git a/src/chage.c b/src/chage.c
|
||||
index aed8e5b..e2902a7 100644
|
||||
--- a/src/chage.c
|
||||
+++ b/src/chage.c
|
||||
@@ -238,7 +238,7 @@ print_day_as_date(long day)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (localtime_r(&date, &tm) == NULL) {
|
||||
+ if (gmtime_r(&date, &tm) == NULL) {
|
||||
puts(_("future"));
|
||||
return;
|
||||
}
|
||||
-375
@@ -1,375 +0,0 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Tue, 18 Feb 2025 00:41:56 +0100
|
||||
Subject: lib/getdate.y: Ignore time-zone information and use UTC
|
||||
|
||||
There is exactly one caller of this function, and it wants a date, not a
|
||||
time. It is useless to be able to parse local dates, because we
|
||||
ultimately store a UTC date. To avoid confusion, unconditionally use
|
||||
UTC. Since this code had important bugs regarding offset, we can safely
|
||||
assume that no existing users rely on being able to use their local
|
||||
date (this never worked correctly).
|
||||
|
||||
Also, the code parsing time zones was quite bad.
|
||||
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/1202>
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/1209>
|
||||
Reported-by: Chris Hofstaedtler <zeha@debian.org>
|
||||
Reported-by: Tim Parenti <tim@timtimeonline.com>
|
||||
Reported-by: Lee Garrett <lgarrett@rocketjump.eu>
|
||||
Cc: Gus Kenion <https://github.com/kenion>
|
||||
Cc: Michael Vetter <jubalh@iodoru.org>
|
||||
Cc: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Cc: Iker Pedrosa <ipedrosa@redhat.com>
|
||||
Cc: "Serge E. Hallyn" <serge@hallyn.com>
|
||||
Cc: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
lib/getdate.y | 225 +++-------------------------------------------------------
|
||||
1 file changed, 10 insertions(+), 215 deletions(-)
|
||||
|
||||
diff --git a/lib/getdate.y b/lib/getdate.y
|
||||
index 20b1f5f..5b1d88d 100644
|
||||
--- a/lib/getdate.y
|
||||
+++ b/lib/getdate.y
|
||||
@@ -92,8 +92,6 @@
|
||||
static int yylex (void);
|
||||
static int yyerror (const char *s);
|
||||
|
||||
-#define EPOCH 1970
|
||||
-#define HOUR(x) ((x) * 60)
|
||||
|
||||
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
|
||||
|
||||
@@ -128,8 +126,6 @@ static int yyHaveDate;
|
||||
static int yyHaveDay;
|
||||
static int yyHaveRel;
|
||||
static int yyHaveTime;
|
||||
-static int yyHaveZone;
|
||||
-static int yyTimezone;
|
||||
static int yyDay;
|
||||
static int yyHour;
|
||||
static int yyMinutes;
|
||||
@@ -151,13 +147,13 @@ static int yyRelYear;
|
||||
enum _MERIDIAN Meridian;
|
||||
}
|
||||
|
||||
-%token tAGO tDAY tDAY_UNIT tDAYZONE tDST tHOUR_UNIT tID
|
||||
+%token tAGO tDAY tDAY_UNIT tHOUR_UNIT tID
|
||||
%token tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
|
||||
-%token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
|
||||
+%token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT
|
||||
|
||||
-%type <Number> tDAY tDAY_UNIT tDAYZONE tHOUR_UNIT tMINUTE_UNIT
|
||||
+%type <Number> tDAY tDAY_UNIT tHOUR_UNIT tMINUTE_UNIT
|
||||
%type <Number> tMONTH tMONTH_UNIT
|
||||
-%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
|
||||
+%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT
|
||||
%type <Meridian> tMERIDIAN o_merid
|
||||
|
||||
%%
|
||||
@@ -169,9 +165,6 @@ spec : /* NULL */
|
||||
item : time {
|
||||
yyHaveTime++;
|
||||
}
|
||||
- | zone {
|
||||
- yyHaveZone++;
|
||||
- }
|
||||
| date {
|
||||
yyHaveDate++;
|
||||
}
|
||||
@@ -200,10 +193,6 @@ time : tUNUMBER tMERIDIAN {
|
||||
yyHour = $1;
|
||||
yyMinutes = $3;
|
||||
yyMeridian = MER24;
|
||||
- yyHaveZone++;
|
||||
- yyTimezone = ($4 < 0
|
||||
- ? -$4 % 100 + (-$4 / 100) * 60
|
||||
- : - ($4 % 100 + ($4 / 100) * 60));
|
||||
}
|
||||
| tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
|
||||
yyHour = $1;
|
||||
@@ -216,22 +205,6 @@ time : tUNUMBER tMERIDIAN {
|
||||
yyMinutes = $3;
|
||||
yySeconds = $5;
|
||||
yyMeridian = MER24;
|
||||
- yyHaveZone++;
|
||||
- yyTimezone = ($6 < 0
|
||||
- ? -$6 % 100 + (-$6 / 100) * 60
|
||||
- : - ($6 % 100 + ($6 / 100) * 60));
|
||||
- }
|
||||
- ;
|
||||
-
|
||||
-zone : tZONE {
|
||||
- yyTimezone = $1;
|
||||
- }
|
||||
- | tDAYZONE {
|
||||
- yyTimezone = $1 - 60;
|
||||
- }
|
||||
- |
|
||||
- tZONE tDST {
|
||||
- yyTimezone = $1 - 60;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -484,91 +457,6 @@ static TABLE const OtherTable[] = {
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
-/* The timezone table. */
|
||||
-static TABLE const TimezoneTable[] = {
|
||||
- { "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */
|
||||
- { "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
|
||||
- { "utc", tZONE, HOUR ( 0) },
|
||||
- { "wet", tZONE, HOUR ( 0) }, /* Western European */
|
||||
- { "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
|
||||
- { "wat", tZONE, HOUR ( 1) }, /* West Africa */
|
||||
- { "at", tZONE, HOUR ( 2) }, /* Azores */
|
||||
- { "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
|
||||
- { "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
|
||||
- { "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
|
||||
- { "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
|
||||
- { "cst", tZONE, HOUR ( 6) }, /* Central Standard */
|
||||
- { "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */
|
||||
- { "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */
|
||||
- { "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
|
||||
- { "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */
|
||||
- { "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
|
||||
- { "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */
|
||||
- { "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
|
||||
- { "hst", tZONE, HOUR (10) }, /* Hawaii Standard */
|
||||
- { "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
|
||||
- { "cat", tZONE, HOUR (10) }, /* Central Alaska */
|
||||
- { "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
|
||||
- { "nt", tZONE, HOUR (11) }, /* Nome */
|
||||
- { "idlw", tZONE, HOUR (12) }, /* International Date Line West */
|
||||
- { "cet", tZONE, -HOUR (1) }, /* Central European */
|
||||
- { "met", tZONE, -HOUR (1) }, /* Middle European */
|
||||
- { "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */
|
||||
- { "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
|
||||
- { "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
|
||||
- { "swt", tZONE, -HOUR (1) }, /* Swedish Winter */
|
||||
- { "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */
|
||||
- { "fwt", tZONE, -HOUR (1) }, /* French Winter */
|
||||
- { "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
|
||||
- { "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
|
||||
- { "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
|
||||
- { "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
|
||||
- { "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
|
||||
- { "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
|
||||
- { "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
|
||||
- { "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
|
||||
- { "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
|
||||
- { "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
|
||||
- { "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
|
||||
- { "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
|
||||
- { "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
|
||||
- { "nzt", tZONE, -HOUR (12) }, /* New Zealand */
|
||||
- { "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
|
||||
- { "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
|
||||
- { "idle", tZONE, -HOUR (12) }, /* International Date Line East */
|
||||
- { NULL, 0, 0 }
|
||||
-};
|
||||
-
|
||||
-/* Military timezone table. */
|
||||
-static TABLE const MilitaryTable[] = {
|
||||
- { "a", tZONE, HOUR ( 1) },
|
||||
- { "b", tZONE, HOUR ( 2) },
|
||||
- { "c", tZONE, HOUR ( 3) },
|
||||
- { "d", tZONE, HOUR ( 4) },
|
||||
- { "e", tZONE, HOUR ( 5) },
|
||||
- { "f", tZONE, HOUR ( 6) },
|
||||
- { "g", tZONE, HOUR ( 7) },
|
||||
- { "h", tZONE, HOUR ( 8) },
|
||||
- { "i", tZONE, HOUR ( 9) },
|
||||
- { "k", tZONE, HOUR ( 10) },
|
||||
- { "l", tZONE, HOUR ( 11) },
|
||||
- { "m", tZONE, HOUR ( 12) },
|
||||
- { "n", tZONE, HOUR (- 1) },
|
||||
- { "o", tZONE, HOUR (- 2) },
|
||||
- { "p", tZONE, HOUR (- 3) },
|
||||
- { "q", tZONE, HOUR (- 4) },
|
||||
- { "r", tZONE, HOUR (- 5) },
|
||||
- { "s", tZONE, HOUR (- 6) },
|
||||
- { "t", tZONE, HOUR (- 7) },
|
||||
- { "u", tZONE, HOUR (- 8) },
|
||||
- { "v", tZONE, HOUR (- 9) },
|
||||
- { "w", tZONE, HOUR (-10) },
|
||||
- { "x", tZONE, HOUR (-11) },
|
||||
- { "y", tZONE, HOUR (-12) },
|
||||
- { "z", tZONE, HOUR ( 0) },
|
||||
- { NULL, 0, 0 }
|
||||
-};
|
||||
-
|
||||
|
||||
|
||||
|
||||
@@ -621,7 +509,6 @@ static int ToYear (int Year)
|
||||
static int LookupWord (char *buff)
|
||||
{
|
||||
register char *p;
|
||||
- register char *q;
|
||||
register const TABLE *tp;
|
||||
int i;
|
||||
bool abbrev;
|
||||
@@ -670,16 +557,6 @@ static int LookupWord (char *buff)
|
||||
}
|
||||
}
|
||||
|
||||
- for (tp = TimezoneTable; tp->name; tp++)
|
||||
- if (streq(buff, tp->name))
|
||||
- {
|
||||
- yylval.Number = tp->value;
|
||||
- return tp->type;
|
||||
- }
|
||||
-
|
||||
- if (streq(buff, "dst"))
|
||||
- return tDST;
|
||||
-
|
||||
for (tp = UnitsTable; tp->name; tp++)
|
||||
if (streq(buff, tp->name))
|
||||
{
|
||||
@@ -708,32 +585,6 @@ static int LookupWord (char *buff)
|
||||
return tp->type;
|
||||
}
|
||||
|
||||
- /* Military timezones. */
|
||||
- if (buff[1] == '\0' && isalpha (*buff))
|
||||
- {
|
||||
- for (tp = MilitaryTable; tp->name; tp++)
|
||||
- if (streq(buff, tp->name))
|
||||
- {
|
||||
- yylval.Number = tp->value;
|
||||
- return tp->type;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /* Drop out any periods and try the timezone table again. */
|
||||
- for (i = 0, p = q = buff; !streq(q, ""); q++)
|
||||
- if (*q != '.')
|
||||
- *p++ = *q;
|
||||
- else
|
||||
- i++;
|
||||
- stpcpy(p, "");
|
||||
- if (0 != i)
|
||||
- for (tp = TimezoneTable; NULL != tp->name; tp++)
|
||||
- if (streq(buff, tp->name))
|
||||
- {
|
||||
- yylval.Number = tp->value;
|
||||
- return tp->type;
|
||||
- }
|
||||
-
|
||||
return tID;
|
||||
}
|
||||
|
||||
@@ -796,34 +647,14 @@ yylex (void)
|
||||
|
||||
#define TM_YEAR_ORIGIN 1900
|
||||
|
||||
-/* Yield A - B, measured in seconds. */
|
||||
-static long difftm (struct tm *a, struct tm *b)
|
||||
-{
|
||||
- int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
- int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
- long days = (
|
||||
- /* difference in day of year */
|
||||
- a->tm_yday - b->tm_yday
|
||||
- /* + intervening leap days */
|
||||
- + ((ay >> 2) - (by >> 2))
|
||||
- - (ay / 100 - by / 100)
|
||||
- + ((ay / 100 >> 2) - (by / 100 >> 2))
|
||||
- /* + difference in years * 365 */
|
||||
- + (long) (ay - by) * 365
|
||||
- );
|
||||
- return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
|
||||
- + (a->tm_min - b->tm_min))
|
||||
- + (a->tm_sec - b->tm_sec));
|
||||
-}
|
||||
-
|
||||
time_t get_date (const char *p, const time_t *now)
|
||||
{
|
||||
- struct tm tm, tm0, *tmp;
|
||||
+ struct tm tm, *tmp;
|
||||
time_t Start;
|
||||
|
||||
yyInput = p;
|
||||
Start = now ? *now : time(NULL);
|
||||
- tmp = localtime (&Start);
|
||||
+ tmp = gmtime(&Start);
|
||||
yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
|
||||
yyMonth = tmp->tm_mon + 1;
|
||||
yyDay = tmp->tm_mday;
|
||||
@@ -841,10 +672,9 @@ time_t get_date (const char *p, const time_t *now)
|
||||
yyHaveDay = 0;
|
||||
yyHaveRel = 0;
|
||||
yyHaveTime = 0;
|
||||
- yyHaveZone = 0;
|
||||
|
||||
if (yyparse ()
|
||||
- || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
|
||||
+ || yyHaveTime > 1 || yyHaveDate > 1 || yyHaveDay > 1)
|
||||
return -1;
|
||||
|
||||
tm.tm_year = ToYear (yyYear) - TM_YEAR_ORIGIN + yyRelYear;
|
||||
@@ -866,39 +696,12 @@ time_t get_date (const char *p, const time_t *now)
|
||||
tm.tm_hour += yyRelHour;
|
||||
tm.tm_min += yyRelMinutes;
|
||||
tm.tm_sec += yyRelSeconds;
|
||||
- tm.tm_isdst = -1;
|
||||
- tm0 = tm;
|
||||
+ tm.tm_isdst = 0;
|
||||
|
||||
- Start = mktime (&tm);
|
||||
+ Start = timegm(&tm);
|
||||
|
||||
if (Start == (time_t) -1)
|
||||
{
|
||||
-
|
||||
- /* Guard against falsely reporting errors near the time_t boundaries
|
||||
- when parsing times in other time zones. For example, if the min
|
||||
- time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
|
||||
- of UTC, then the min localtime value is 1970-01-01 08:00:00; if
|
||||
- we apply mktime to 1970-01-01 00:00:00 we will get an error, so
|
||||
- we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
|
||||
- zone by 24 hours to compensate. This algorithm assumes that
|
||||
- there is no DST transition within a day of the time_t boundaries. */
|
||||
- if (yyHaveZone)
|
||||
- {
|
||||
- tm = tm0;
|
||||
- if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
|
||||
- {
|
||||
- tm.tm_mday++;
|
||||
- yyTimezone -= 24 * 60;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- tm.tm_mday--;
|
||||
- yyTimezone += 24 * 60;
|
||||
- }
|
||||
- Start = mktime (&tm);
|
||||
- }
|
||||
-
|
||||
- if (Start == (time_t) -1)
|
||||
return Start;
|
||||
}
|
||||
|
||||
@@ -906,19 +709,11 @@ time_t get_date (const char *p, const time_t *now)
|
||||
{
|
||||
tm.tm_mday += ((yyDayNumber - tm.tm_wday + 7) % 7
|
||||
+ 7 * (yyDayOrdinal - (0 < yyDayOrdinal)));
|
||||
- Start = mktime (&tm);
|
||||
+ Start = timegm(&tm);
|
||||
if (Start == (time_t) -1)
|
||||
return Start;
|
||||
}
|
||||
|
||||
- if (yyHaveZone)
|
||||
- {
|
||||
- long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
|
||||
- if ((Start + delta < Start) != (delta < 0))
|
||||
- return -1; /* time_t overflow */
|
||||
- Start += delta;
|
||||
- }
|
||||
-
|
||||
return Start;
|
||||
}
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 13:44:55 +0100
|
||||
Subject: src/chfn.c: Add local variable to refer to the separated field
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 1799d6b..3fc94dc 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -220,18 +220,20 @@ static char *copy_field (char *in, char *out, char *extra)
|
||||
char *cp = NULL;
|
||||
|
||||
while (NULL != in) {
|
||||
+ const char *f;
|
||||
+
|
||||
+ f = in;
|
||||
cp = stpsep(in, ",");
|
||||
|
||||
- if (strchr (in, '=') == NULL) {
|
||||
+ if (strchr(f, '=') == NULL)
|
||||
break;
|
||||
- }
|
||||
|
||||
if (NULL != extra) {
|
||||
if (!streq(extra, "")) {
|
||||
strcat (extra, ",");
|
||||
}
|
||||
|
||||
- strcat (extra, in);
|
||||
+ strcat(extra, f);
|
||||
}
|
||||
in = cp;
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 13:23:37 +0100
|
||||
Subject: src/chfn.c: Partially revert "lib/,
|
||||
src/: Use strsep(3) instead of its pattern"
|
||||
|
||||
This partially reverts commit 16cb664865541162c504a6f5ef5ca4b38b5e0c9a.
|
||||
|
||||
I'll try to reintroduce this change more carefully.
|
||||
For now, let's revert to a known-good state.
|
||||
|
||||
The problem was due to accidentally ignoring the effects of the 'break'
|
||||
on the 'cp' variable.
|
||||
|
||||
Fixes: 16cb66486554 (2024-07-01; "lib/, src/: Use strsep(3) instead of its pattern")
|
||||
Closes: <https://github.com/shadow-maint/shadow/issues/1210>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1213>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1212>
|
||||
Reported-by: Chris Hofstaedtler <zeha@debian.org>
|
||||
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 17 +++++++++++------
|
||||
1 file changed, 11 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 4c96fba..f06cb44 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -216,27 +216,32 @@ static void new_fields (void)
|
||||
*/
|
||||
static char *copy_field (char *in, char *out, char *extra)
|
||||
{
|
||||
+ char *cp = NULL;
|
||||
+
|
||||
while (NULL != in) {
|
||||
- char *f;
|
||||
+ cp = strchr (in, ',');
|
||||
+ if (NULL != cp) {
|
||||
+ *cp++ = '\0';
|
||||
+ }
|
||||
|
||||
- f = strsep(&in, ",");
|
||||
-
|
||||
- if (strchr(f, '=') == NULL)
|
||||
+ if (strchr (in, '=') == NULL) {
|
||||
break;
|
||||
+ }
|
||||
|
||||
if (NULL != extra) {
|
||||
if (!streq(extra, "")) {
|
||||
strcat (extra, ",");
|
||||
}
|
||||
|
||||
- strcat(extra, f);
|
||||
+ strcat (extra, in);
|
||||
}
|
||||
+ in = cp;
|
||||
}
|
||||
if ((NULL != in) && (NULL != out)) {
|
||||
strcpy (out, in);
|
||||
}
|
||||
|
||||
- return in;
|
||||
+ return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1,33 +0,0 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 13:40:02 +0100
|
||||
Subject: src/chfn.c: Use stpsep() instead of its pattern
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 6 ++----
|
||||
1 file changed, 2 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index f06cb44..1799d6b 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "string/strcmp/streq.h"
|
||||
#include "string/strcpy/strtcpy.h"
|
||||
#include "string/strdup/xstrdup.h"
|
||||
+#include "string/strtok/stpsep.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -219,10 +220,7 @@ static char *copy_field (char *in, char *out, char *extra)
|
||||
char *cp = NULL;
|
||||
|
||||
while (NULL != in) {
|
||||
- cp = strchr (in, ',');
|
||||
- if (NULL != cp) {
|
||||
- *cp++ = '\0';
|
||||
- }
|
||||
+ cp = stpsep(in, ",");
|
||||
|
||||
if (strchr (in, '=') == NULL) {
|
||||
break;
|
||||
@@ -1,47 +0,0 @@
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 17 Feb 2025 15:33:46 +0100
|
||||
Subject: src/chfn.c: copy_field(): Rename local variable
|
||||
|
||||
This makes it more obvious what that pointer is.
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/chfn.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/chfn.c b/src/chfn.c
|
||||
index 3fc94dc..d62bb8a 100644
|
||||
--- a/src/chfn.c
|
||||
+++ b/src/chfn.c
|
||||
@@ -217,13 +217,13 @@ static void new_fields (void)
|
||||
*/
|
||||
static char *copy_field (char *in, char *out, char *extra)
|
||||
{
|
||||
- char *cp = NULL;
|
||||
+ char *next = NULL;
|
||||
|
||||
while (NULL != in) {
|
||||
const char *f;
|
||||
|
||||
f = in;
|
||||
- cp = stpsep(in, ",");
|
||||
+ next = stpsep(in, ",");
|
||||
|
||||
if (strchr(f, '=') == NULL)
|
||||
break;
|
||||
@@ -235,13 +235,13 @@ static char *copy_field (char *in, char *out, char *extra)
|
||||
|
||||
strcat(extra, f);
|
||||
}
|
||||
- in = cp;
|
||||
+ in = next;
|
||||
}
|
||||
if ((NULL != in) && (NULL != out)) {
|
||||
strcpy (out, in);
|
||||
}
|
||||
|
||||
- return cp;
|
||||
+ return next;
|
||||
}
|
||||
|
||||
/*
|
||||
Reference in New Issue
Block a user