[Pkg-shadow-commits] r1204 - in trunk/debian: . patches
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Tue Jun 19 15:01:37 UTC 2007
Author: nekral-guest
Date: 2007-06-19 15:01:37 +0000 (Tue, 19 Jun 2007)
New Revision: 1204
Added:
trunk/debian/patches/412_lastlog_-u_numerical_range
Modified:
trunk/debian/changelog
trunk/debian/patches/series
Log:
Allow numerical ID and range of IDs as the lastlog -u argument.
Closes: #259494
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2007-06-19 10:50:11 UTC (rev 1203)
+++ trunk/debian/changelog 2007-06-19 15:01:37 UTC (rev 1204)
@@ -13,6 +13,8 @@
update the passwords. Thus functionnalities provided by PAM modules are
not present in chgpasswd (e.g. writting the old password in
/etc/security/opasswd). Closes: #396726
+ - 412_lastlog_-u_numerical_range: allow numerical UID and range of IDs in
+ argument to lastog -u. Closes: #259494
* Debian packaging fixes:
- 506_relaxed_usernames: do not allow spaces in usernames. This was at
least broken with username starting with a space or tabulation (the user
Added: trunk/debian/patches/412_lastlog_-u_numerical_range
===================================================================
--- trunk/debian/patches/412_lastlog_-u_numerical_range (rev 0)
+++ trunk/debian/patches/412_lastlog_-u_numerical_range 2007-06-19 15:01:37 UTC (rev 1204)
@@ -0,0 +1,153 @@
+Goal: Sipport numerical UID and ranges in lastlog -u
+Fixes: #259494
+
+Status wrt upstream: not reported yet.
+
+Note: It also allows to mix -u and -t
+
+Index: shadow-4.0.18.1/man/lastlog.8.xml
+===================================================================
+--- shadow-4.0.18.1.orig/man/lastlog.8.xml 2007-06-19 13:23:42.000000000 +0100
++++ shadow-4.0.18.1/man/lastlog.8.xml 2007-06-19 14:35:26.000000000 +0100
+@@ -71,22 +71,20 @@
+ <varlistentry>
+ <term>
+ <option>-u</option>, <option>--user</option>
+- <replaceable>LOGIN</replaceable>
++ <replaceable>LOGIN</replaceable>|<replaceable>RANGE</replaceable>
+ </term>
+ <listitem>
+ <para>Print the lastlog record for user with specified
+ <emphasis remap='I'>LOGIN</emphasis> only.
+ </para>
+- </listitem>
+- </varlistentry>
+- </variablelist>
+- <variablelist remap='TP'>
+- <varlistentry>
+- <term>
+- The <option>-t</option> flag overrides the use of <option>-u</option>.
+- </term>
+- <listitem>
+- <para></para>
++ <para>Instead of a login name, <command>lastlog</command> also
++ accepts a numerical user ID or a <replaceable>RANGE</replaceable> of
++ users. This <replaceable>RANGE</replaceable> of users can be
++ specified with a min and max values
++ (<replaceable>UID_MIN-UID_MAX</replaceable>), a max value
++ (<replaceable>-UID_MAX</replaceable>) or a min value
++ (<replaceable>UID_MIN-</replaceable>).
++ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+Index: shadow-4.0.18.1/src/lastlog.c
+===================================================================
+--- shadow-4.0.18.1.orig/src/lastlog.c 2007-06-19 13:23:35.000000000 +0100
++++ shadow-4.0.18.1/src/lastlog.c 2007-06-19 14:22:21.000000000 +0100
+@@ -51,6 +51,8 @@
+ */
+ static FILE *lastlogfile; /* lastlog file stream */
+ static off_t user; /* one single user, specified on command line */
++static long umin; /* one single user, specified on command line */
++static long umax; /* one single user, specified on command line */
+ static int days; /* number of days to consider for print command */
+ static time_t seconds; /* that number of days in seconds */
+ static int inverse_days; /* number of days to consider for print command */
+@@ -58,6 +60,7 @@
+
+
+ static int uflg = 0; /* set if user is a valid user id */
++static int urange = 0; /* set if user is a valid user id range */
+ static int tflg = 0; /* print is restricted to most recent days */
+ static int bflg = 0; /* print excludes most recent days */
+ static struct lastlog lastlog; /* scratch structure to play with ... */
+@@ -127,26 +130,16 @@
+ {
+ off_t offset;
+
+- if (uflg) {
+- offset = user * sizeof lastlog;
+-
+- if (fstat (fileno (lastlogfile), &statbuf)) {
+- perror (LASTLOG_FILE);
+- return;
+- }
+- if (offset >= statbuf.st_size)
+- return;
+-
+- fseeko (lastlogfile, offset, SEEK_SET);
+- if (fread ((char *) &lastlog, sizeof lastlog, 1,
+- lastlogfile) == 1)
+- print_one (pwent);
+- else
+- perror (LASTLOG_FILE);
+- } else {
++ {
+ setpwent ();
+ while ((pwent = getpwent ())) {
++ if (uflg && user != pwent->pw_uid)
++ continue;
+ user = pwent->pw_uid;
++ if (urange &&
++ ((umin != -1 && user < umin) ||
++ (umax != -1 && user > umax)))
++ continue;
+ offset = user * sizeof lastlog;
+
+ fseeko (lastlogfile, offset, SEEK_SET);
+@@ -199,15 +192,47 @@
+ bflg++;
+ break;
+ case 'u':
++ /*
++ * The user can be:
++ * - a login name
++ * - numerical
++ * - a numerical login ID
++ * - a range (-x, x-, x-y)
++ */
+ pwent = getpwnam (optarg);
+- if (!pwent) {
+- fprintf (stderr,
+- _("Unknown User: %s\n"),
+- optarg);
+- exit (1);
++ if (pwent) {
++ uflg = 1;
++ user = pwent->pw_uid;
++ } else {
++ char *endptr = NULL;
++ user = strtol(optarg, &endptr, 10);
++ if (*optarg != '\0' && *endptr == '\0') {
++ if (user < 0) {
++ /* -<userid> */
++ urange = 1;
++ umin = -1;
++ umax = -user;
++ } else {
++ /* <userid> */
++ uflg = 1;
++ }
++ } else if (endptr[0] == '-' && endptr[1] == '\0') {
++ /* <userid>- */
++ urange = 1;
++ umin = user;
++ umax = -1;
++ } else if (*endptr == '-') {
++ /* <userid>-<userid> */
++ urange = 1;
++ umin = user;
++ umax = atol(endptr+1);
++ } else {
++ fprintf (stderr,
++ _("Unknown user or range: %s\n"),
++ optarg);
++ exit (1);
++ }
+ }
+- uflg++;
+- user = pwent->pw_uid;
+ break;
+ default:
+ usage ();
Modified: trunk/debian/patches/series
===================================================================
--- trunk/debian/patches/series 2007-06-19 10:50:11 UTC (rev 1203)
+++ trunk/debian/patches/series 2007-06-19 15:01:37 UTC (rev 1204)
@@ -60,3 +60,4 @@
201_fix_man_su_fr
202_it_man_uses_gettext
411_chpasswd_document_no_pam
+412_lastlog_-u_numerical_range
More information about the Pkg-shadow-commits
mailing list