Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead beef #1230

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Feb 24, 2025

We didn't even have prototypes for these APIs since long ago, when the prototypes were removed, but misteriously the implementations remained.

Both glibc and musl provide getspnam(3), so this file was effectively being ignored by the compiler. Just remove it.

Also remove the check for getspnam, which isn't used elsewhere.

Fixes: 0ee095a (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (4.0.7)")
Closes: #1228


Revisions:

v2
  • Remove other dead code found by @zeha
$ git range-diff master gh/sh sh
1:  22f49d87 = 1:  22f49d87 configure.ac, lib/shadow.c, po/: Remove dead file
-:  -------- > 2:  036f5d7e configure.ac, contrib/, src/: Remove obsolete check
-:  -------- > 3:  97856757 configure.ac: Remove unused check for futimes(3)
v2b
  • Remove dead code I forgot to remove in v2.
$ git range-diff master gh/sh sh
1:  22f49d87 = 1:  22f49d87 configure.ac, lib/shadow.c, po/: Remove dead file
2:  036f5d7e ! 2:  4bb6df21 configure.ac, contrib/, src/: Remove obsolete check
    @@ Metadata
     Author: Alejandro Colomar <alx@kernel.org>
     
      ## Commit message ##
    -    configure.ac, contrib/, src/: Remove obsolete check
    +    configure.ac, contrib/, src/: Remove dead code
     
         Both glibc and musl provide getusershell(3).  It's an API from 4.3BSD,
         according to the manual page, so let's assume it exists everywhere that
    @@ Commit message
         Reported-by: Chris Hofstaedtler <zeha@debian.org>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
    +    f
    +
      ## configure.ac ##
     @@ configure.ac: dnl shadow now uses the libc's shadow implementation
      AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
    @@ src/chsh.c: static bool shell_is_listed (const char *sh)
        }
        endusershell ();
     -#else
    -+
    -   char *buf = NULL;
    -   FILE *fp;
    -   size_t n = 0;
    +-  char *buf = NULL;
    +-  FILE *fp;
    +-  size_t n = 0;
    + 
    +-  fp = fopen (SHELLS_FILE, "r");
    +-  if (NULL == fp) {
    +-          return false;
    +-  }
    +-
    +-  while (getline (&buf, &n, fp) != -1) {
    +-          if (buf[0] != '/') {
    +-                  continue;
    +-          }
    +-
    +-          if (streq(buf, sh)) {
    +-                  found = true;
    +-                  break;
    +-          }
    +-  }
    +-
    +-  free(buf);
    +-  fclose (fp);
    +-#endif
    +   return found;
    + }
    + #endif /* with HAVE_VENDORDIR */
3:  97856757 = 3:  9c7bd91a configure.ac: Remove unused check for futimes(3)
v2c
  • Remove stray 'f' in commit message (it was a glitch of rebasing). [@zeha]
$ git range-diff master gh/sh sh
1:  22f49d87 = 1:  22f49d87 configure.ac, lib/shadow.c, po/: Remove dead file
2:  4bb6df21 ! 2:  11addd70 configure.ac, contrib/, src/: Remove dead code
    @@ Commit message
         Reported-by: Chris Hofstaedtler <zeha@debian.org>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
    -    f
    -
      ## configure.ac ##
     @@ configure.ac: dnl shadow now uses the libc's shadow implementation
      AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
3:  9c7bd91a = 3:  239bfe65 configure.ac: Remove unused check for futimes(3)
v2d
  • Rebase
$ git range-diff master..gh/sh shadow/master..sh
1:  22f49d87 = 1:  7e0a3f7b configure.ac, lib/shadow.c, po/: Remove dead file
2:  11addd70 = 2:  c15827cd configure.ac, contrib/, src/: Remove dead code
3:  239bfe65 = 3:  c140a255 configure.ac: Remove unused check for futimes(3)
v2e
  • Improve commit subject line
$ git range-diff shadow/master gh/sh sh
1:  7e0a3f7b ! 1:  d1c7dbb2 configure.ac, lib/shadow.c, po/: Remove dead file
    @@ Metadata
     Author: Alejandro Colomar <alx@kernel.org>
     
      ## Commit message ##
    -    configure.ac, lib/shadow.c, po/: Remove dead file
    +    lib/shadow.c, configure.ac, po/: Remove dead file <lib/shadow.c>
     
         We didn't even have prototypes for these APIs since long ago, when the
         prototypes were removed, but misteriously the implementations remained.
2:  c15827cd = 2:  70478719 configure.ac, contrib/, src/: Remove dead code
3:  c140a255 = 3:  8e57d32a configure.ac: Remove unused check for futimes(3)
v3f
  • Fix commit subject line
$ git range-diff shadow/master gh/sh sh
1:  d1c7dbb2 ! 1:  c7e47809 lib/shadow.c, configure.ac, po/: Remove dead file <lib/shadow.c>
    @@ Metadata
     Author: Alejandro Colomar <alx@kernel.org>
     
      ## Commit message ##
    -    lib/shadow.c, configure.ac, po/: Remove dead file <lib/shadow.c>
    +    lib/, configure.ac, po/: Remove dead file <lib/shadow.c>
     
         We didn't even have prototypes for these APIs since long ago, when the
         prototypes were removed, but misteriously the implementations remained.
2:  70478719 = 2:  36766600 configure.ac, contrib/, src/: Remove dead code
3:  8e57d32a = 3:  8c91195e configure.ac: Remove unused check for futimes(3)

@alejandro-colomar alejandro-colomar force-pushed the sh branch 2 times, most recently from d959af8 to 22f49d8 Compare February 24, 2025 22:47
@alejandro-colomar alejandro-colomar changed the title configure.ac, lib/shadow.c: Remove dead file Remove dead beef Feb 24, 2025
@zeha
Copy link
Contributor

zeha commented Feb 25, 2025

4bb6df2 commit message has a stray "f" at the end

@alejandro-colomar
Copy link
Collaborator Author

4bb6df2 commit message has a stray "f" at the end

Thanks! That was a glitch of squashing a commit with a dummy message, and forgetting to remove the name.

@alejandro-colomar alejandro-colomar force-pushed the sh branch 2 times, most recently from c140a25 to 8e57d32 Compare March 3, 2025 20:59
We didn't even have prototypes for these APIs since long ago, when the
prototypes were removed, but misteriously the implementations remained.

Both glibc and musl provide getspnam(3), so this file was effectively
being ignored by the compiler.  Just remove it.

Also remove the check for getspnam, which isn't used elsewhere.

Fixes: 0ee095a (2007-10-07; "[svn-upgrade] Integrating new upstream version, shadow (4.0.7)")
Closes: <shadow-maint#1228>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Both glibc and musl provide getusershell(3).  It's an API from 4.3BSD,
according to the manual page, so let's assume it exists everywhere that
we would care, even if it's not in POSIX.

Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lib/shadow.c is 0xDEADBEEF
2 participants