shadow-maint/shadow

Bogus comment about a -s flag in passwd.c

alejandro-colomar opened this issue · 3 comments

* -s execute chsh command to interpret flags

Link: #927 (comment) (Cc: @thalman)

The comment dates back to the second commit (shadow 19990709), which adds the file:

$ git blame HEAD -- src/passwd.c | grep '[[:space:]]-s'
8451bed8b (nekral-guest        2007-10-07 11:47:01 +0000  685)  *	-s	execute chsh command to interpret flags
$ git show 8451bed8b -- src/passwd.c | grep '[[:space:]]-s'
- *	-s	execute chsh command to interpret flags
+ *	-s	execute chsh command to interpret flags
$ git blame 8451bed8b^ -- src/passwd.c | grep '[[:space:]]-s'
45c6603cc (nekral-guest 2007-10-07 11:44:02 +0000 588)  *	-s	execute chsh command to interpret flags
$ git show 45c6603cc -- src/passwd.c | grep '[[:space:]]-s'
+	fprintf(stderr, _("usage: %s [ -f | -s ] [ name ]\n"), Prog);
+ *	-s	execute chsh command to interpret flags
$ git show 45c6603cc --stat -- '**/passwd.c'
commit 45c6603cc86c5881b00ac40e0f9fe548c30ff6be
Author: nekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Date:   Sun Oct 7 11:44:02 2007 +0000

    [svn-upgrade] Integrating new upstream version, shadow (19990709)

 src/passwd.c | 1417 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 1417 insertions(+)

But there has never been such an option:

$ git blame HEAD -- src/passwd.c | grep while.*getopt_long
43e60eb68 (Jaroslav Jindrak    2023-04-21 20:50:41 +0200  760) 		while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:P:Suw:x:",
$ git show 43e60eb68 -- src/passwd.c | grep while.*getopt_long
-		while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:Suw:x:",
+		while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:P:Suw:x:",
$ git blame 43e60eb68^ -- src/passwd.c | grep while.*getopt_long
ec2b9f59f (nekral-guest        2011-11-06 18:38:16 +0000  784) 		while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:Suw:x:",
$ git show ec2b9f59f -- src/passwd.c | grep while.*getopt_long
-		while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
+		while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:Suw:x:",
$ git blame ec2b9f59f^ -- src/passwd.c | grep while.*getopt_long
91b60a955 (nekral-guest 2009-09-04 23:02:33 +0000  818) 		while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
$ git show 91b60a955 -- src/passwd.c | grep while.*getopt_long
-		while ((c = getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
+		while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
$ git blame 91b60a955^ -- src/passwd.c | grep while.*getopt_long
1db4402db (nekral-guest 2009-04-28 20:55:10 +0000  814) 		while ((c = getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
$ git show 1db4402db -- src/passwd.c | grep while.*getopt_long
+		while ((c = getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
$ git show 1db4402db -- src/passwd.c | grep getopt_long
-			getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
+		while ((c = getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
$ git blame 1db4402db^ -- src/passwd.c | grep getopt_long
8451bed8b (nekral-guest 2007-10-07 11:47:01 +0000  812) 			getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
$ git show 8451bed8b -- src/passwd.c | grep getopt_long
+			getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
$ git show 8451bed8b -- src/passwd.c | grep getopt
+#include <getopt.h>
-	while ((flag = getopt (argc, argv, "adei:kln:qr:Suw:x:")) != EOF) {
+			getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
$ git blame 8451bed8b^ -- src/passwd.c | grep getopt
b48129fcb (nekral-guest 2007-10-07 11:46:34 +0000 673) 	while ((flag = getopt (argc, argv, "adei:kln:qr:Suw:x:")) != EOF) {
$ git show b48129fcb -- src/passwd.c | grep getopt
-	while ((flag = getopt (argc, argv, "adlqr:uSekn:x:i:w:")) != EOF) {
+	while ((flag = getopt (argc, argv, "adei:kln:qr:Suw:x:")) != EOF) {
$ git blame b48129fcb^ -- src/passwd.c | grep getopt8c50e0610 (nekral-guest 2007-10-07 11:46:25 +0000 673) 	while ((flag = getopt (argc, argv, "adlqr:uSekn:x:i:w:")) != EOF) {
$ git show 8c50e0610 -- src/passwd.c | grep getopt
-	while ((flag = getopt (argc, argv, FLAGS)) != EOF) {
+	while ((flag = getopt (argc, argv, "adlqr:uSekn:x:i:w:")) != EOF) {
$ git show 8c50e0610^:src/passwd.c | grepc -tm FLAGS
(standard input):#define FLAGS "adlqr:uSekn:x:i:w:"
(standard input):# define FLAGS "adlqr:uS"
$ git show 8c50e0610^:src/passwd.c | grepc -tm -C1 FLAGS
(standard input)-#ifdef SHADOWPWD
(standard input):#define FLAGS "adlqr:uSekn:x:i:w:"
(standard input)-#else
(standard input):# define FLAGS "adlqr:uS"
(standard input)-#endif
$ git blame 8c50e0610^ -- src/passwd.c | grep define.FLAGS
45c6603cc (nekral-guest 2007-10-07 11:44:02 +0000 719) #define FLAGS "adlqr:uSekn:x:i:w:"
effd479bf (nekral-guest 2007-10-07 11:45:23 +0000 721) # define FLAGS "adlqr:uS"
$ git show effd479bf -- src/passwd.c | grep define.FLAGS
 #define FLAGS "adlqr:uSekn:x:i:w:"
-#define FLAGS "adlqr:uSekn:x:i:w:t"
-#define FLAGS "adlqr:uS"
-#define FLAGS "adlqr:uSt"
+# define FLAGS "adlqr:uS"
$ git blame effd479bf^ -- src/passwd.c | grep define.FLAGS
45c6603cc (nekral-guest 2007-10-07 11:44:02 +0000  994) #define FLAGS "adlqr:uSekn:x:i:w:"
45c6603cc (nekral-guest 2007-10-07 11:44:02 +0000  997) #define FLAGS "adlqr:uSekn:x:i:w:t"
45c6603cc (nekral-guest 2007-10-07 11:44:02 +0000 1002) #define FLAGS "adlqr:uS"
45c6603cc (nekral-guest 2007-10-07 11:44:02 +0000 1005) #define FLAGS "adlqr:uSt"
$ git show 45c6603cc -- src/passwd.c | grep define.FLAGS
+#define FLAGS "adlqr:uSekn:x:i:w:"
+#define FLAGS "adlqr:uSekn:x:i:w:t"
+#define FLAGS "adlqr:uSekn:x:"
+#define FLAGS "adlqr:uSekn:x:t"
+#define FLAGS "adlqr:uS"
+#define FLAGS "adlqr:uSt"
$ git show 45c6603cc --stat -- '**/passwd.c'
commit 45c6603cc86c5881b00ac40e0f9fe548c30ff6be
Author: nekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Date:   Sun Oct 7 11:44:02 2007 +0000

    [svn-upgrade] Integrating new upstream version, shadow (19990709)

 src/passwd.c | 1417 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 1417 insertions(+)

The weird thing is that I would have suspected that this would be a leftover of some copy&paste from somewhere else, so that I would find a copy somewhere else in the project, but didn't:

$ git checkout 45c6603cc 
HEAD is now at 45c6603c [svn-upgrade] Integrating new upstream version, shadow (19990709)
$ grep -rn 'execute .* command to interpret'
src/passwd.c:1000: *	-g	execute gpasswd command to interpret flags
src/passwd.c:1001: *	-f	execute chfn command to interpret flags
src/passwd.c:1002: *	-s	execute chsh command to interpret flags
$ grep -rn -- '-s  '
src/passwd.c:1002: *	-s	execute chsh command to interpret flags

Maybe it has some relation to the -f comment, but I don't know why it was added.

Anyway, I guess we can safely remove that line.

Oh, and that -f comment also seems to refer to a non-existent flag. @hallyn , do you know some history that I don't?

And -g too.

Oh, and that -f comment also seems to refer to a non-existent flag. @hallyn , do you know some history that I don't?

And -g too.

No. Looks like passwd in other OSs had some flags like that. Someone with the old pre-git trees could spelunk if they like. But let's just document what's in the code now.