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

Move shadow APIs to lib/shadow/ #1197

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

Conversation

alejandro-colomar
Copy link
Collaborator

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


Revisions:

v1b
  • Rebase
$ git range-diff master..gh/shadow shadow/master..shadow
 1:  ca7fc68d !  1:  5882c687 lib/shadow/gshadow/, lib/: putsgent(): Move to separate file
    @@ lib/shadow/gshadow/putsgent.c (new)
     + * writes the result to the given stream.  This is the logical
     + * opposite of fgetsgent.
     + */
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +int
     +putsgent(const struct sgrp *sgrp, FILE *fp)
     +{
    @@ lib/shadow/gshadow/putsgent.h (new)
     +#include "gshadow_.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +int putsgent(const struct sgrp *sgrp, FILE *fp);
 2:  900eddbd =  2:  0c2830e3 lib/shadow/gshadow/, lib/: gshadow: Move to separate file and rename
 3:  9e533b79 !  3:  c243ddd9 lib/shadow/gshadow/, lib/, src/: endsgent(): Move to separate file
    @@ lib/shadow/gshadow/endsgent.c (new)
     +#include "shadow/gshadow/gshadow.h"
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +void
     +endsgent(void)
     +{
    @@ lib/shadow/gshadow/endsgent.h (new)
     +#include <config.h>
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +void endsgent(void);
 4:  ed05446b =  4:  02fc437b lib/shadow/gshadow/gshadow.h, lib/, src/: GSHADOW_FILE: Move definition and rename it
 5:  ce49f474 !  5:  8aa68871 lib/shadow/gshadow/, lib/: setsgent(): Move to separate file
    @@ lib/shadow/gshadow/setsgent.c (new)
     +#include "shadow/gshadow/gshadow.h"
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +void
     +setsgent(void)
     +{
    @@ lib/shadow/gshadow/setsgent.h (new)
     +#include <config.h>
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +void setsgent(void);
 6:  72dab352 !  6:  2aa3f65d lib/shadow/gshadow/, lib/, src/: struct sgrp: Move to separate file
    @@ lib/shadow/gshadow/putsgent.h
     +#include "shadow/gshadow/sgrp.h"
      
      
    - #if defined(HAVE_GSHADOW_H)
    + #if __has_include(<gshadow.h>)
     
      ## lib/shadow/gshadow/sgrp.c (new) ##
     @@
    @@ lib/shadow/gshadow/sgrp.h (new)
     +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_SGRP_H_
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp {
 7:  b0d63a72 !  7:  66b0763d lib/shadow/gshadow/, lib/: fgetsgent(): Move to separate file
    @@ lib/shadow/gshadow/fgetsgent.c (new)
     + * fgetsgent() reads the next line from the provided stream and
     + * converts it to a (struct sgrp).  NULL is returned on EOF.
     + */
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +struct sgrp *
     +fgetsgent(FILE *fp)
     +{
    @@ lib/shadow/gshadow/fgetsgent.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *fgetsgent(FILE *stream);
 8:  a7822d17 !  8:  51c7ad87 lib/shadow/gshadow/, lib/: sgetsgent(): Move to separate file
    @@ lib/shadow/gshadow/sgetsgent.c (new)
     +#define FIELDS    4
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +static struct sgrp  sgroup = {};
     +
     +
    @@ lib/shadow/gshadow/sgetsgent.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *sgetsgent(const char *);
 9:  1f7b88f4 !  9:  b3a67122 lib/shadow/gshadow/, lib/, src/: getsgnam(): Move to separate file
    @@ lib/shadow/gshadow/getsgnam.c (new)
     +/*
     + * getsgnam - get a shadow group entry by name
     + */
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +struct sgrp *
     +getsgnam(const char *name)
     +{
    @@ lib/shadow/gshadow/getsgnam.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *getsgnam(const char *);
10:  f3b9c46e ! 10:  c3ea1881 lib/shadow/gshadow/, lib/: getsgent(): Move to separate file
    @@ lib/gshadow.c (deleted)
     -
     -#include <config.h>
     -
    --#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    +-#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     -
     -#ident "$Id$"
     -
    @@ lib/shadow/gshadow/getsgent.c (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +/*
     + * getsgent - get a single shadow group entry
     + */
    @@ lib/shadow/gshadow/getsgent.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *getsgent(void);
11:  f1216144 ! 11:  2b373a55 lib/: GSHADOW: Remove unused macro
    @@ lib/gshadow_.h (deleted)
     -#define SHADOW_INCLUDE_LIB_GSHADOW__H_
     -
     -
    --#if defined(HAVE_GSHADOW_H)
    +-#if __has_include(<gshadow.h>)
     -# include <gshadow.h>
     -#else
     -
    @@ lib/gshadow_.h (deleted)
     -#define   GSHADOW "/etc/gshadow"
     -
     -
    --#endif  // !HAVE_GSHADOW_H
    +-#endif  // !__has_include(<gshadow.h>)
     -#endif  // include guard
12:  64dc60fc = 12:  ca661d7e lib/, po/: sgetgrent(): Move to under lib/shadow/group/
13:  819db775 = 13:  e7293129 lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/
v1c
  • Rebase
$ git range-diff master..gh/shadow shadow/master..shadow
 1:  5882c687 =  1:  4389741a lib/shadow/gshadow/, lib/: putsgent(): Move to separate file
 2:  0c2830e3 =  2:  a2792533 lib/shadow/gshadow/, lib/: gshadow: Move to separate file and rename
 3:  c243ddd9 =  3:  df19bcf0 lib/shadow/gshadow/, lib/, src/: endsgent(): Move to separate file
 4:  02fc437b =  4:  e612ae79 lib/shadow/gshadow/gshadow.h, lib/, src/: GSHADOW_FILE: Move definition and rename it
 5:  8aa68871 =  5:  aa4588ff lib/shadow/gshadow/, lib/: setsgent(): Move to separate file
 6:  2aa3f65d =  6:  188b75be lib/shadow/gshadow/, lib/, src/: struct sgrp: Move to separate file
 7:  66b0763d =  7:  dd092a8f lib/shadow/gshadow/, lib/: fgetsgent(): Move to separate file
 8:  51c7ad87 =  8:  84ca3b10 lib/shadow/gshadow/, lib/: sgetsgent(): Move to separate file
 9:  b3a67122 =  9:  13c382c7 lib/shadow/gshadow/, lib/, src/: getsgnam(): Move to separate file
10:  c3ea1881 = 10:  b453908b lib/shadow/gshadow/, lib/: getsgent(): Move to separate file
11:  2b373a55 = 11:  bb9fb4cb lib/: GSHADOW: Remove unused macro
12:  ca661d7e = 12:  08c1562e lib/, po/: sgetgrent(): Move to under lib/shadow/group/
13:  e7293129 = 13:  a5079cb6 lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/
v2
  • Add comments expanding the meaning of the letter soup API names. [@hallyn ]
$ git range-diff shadow/master gh/shadow shadow
 1:  4389741a !  1:  4777704a lib/shadow/gshadow/, lib/: putsgent(): Move to separate file
    @@ lib/shadow/gshadow/putsgent.c (new)
     + * opposite of fgetsgent.
     + */
     +#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
    ++// put shadow group entry
     +int
     +putsgent(const struct sgrp *sgrp, FILE *fp)
     +{
 2:  a2792533 =  2:  1fc9be8a lib/shadow/gshadow/, lib/: gshadow: Move to separate file and rename
 3:  df19bcf0 !  3:  15cbe6a7 lib/shadow/gshadow/, lib/, src/: endsgent(): Move to separate file
    @@ lib/shadow/gshadow/endsgent.c (new)
     +
     +
     +#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
    ++// end-working-with shadow group entries
     +void
     +endsgent(void)
     +{
 4:  e612ae79 =  4:  5105aeae lib/shadow/gshadow/gshadow.h, lib/, src/: GSHADOW_FILE: Move definition and rename it
 5:  aa4588ff !  5:  df996ad3 lib/shadow/gshadow/, lib/: setsgent(): Move to separate file
    @@ lib/shadow/gshadow/setsgent.c (new)
     +
     +
     +#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
    ++// set-resources-for-working-with shadow group entries
     +void
     +setsgent(void)
     +{
 6:  188b75be =  6:  de18a731 lib/shadow/gshadow/, lib/, src/: struct sgrp: Move to separate file
 7:  dd092a8f !  7:  694d0ada lib/shadow/gshadow/, lib/: fgetsgent(): Move to separate file
    @@ lib/shadow/gshadow/fgetsgent.c (new)
     + * converts it to a (struct sgrp).  NULL is returned on EOF.
     + */
     +#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
    ++// from-FILE get-next shadow group entry
     +struct sgrp *
     +fgetsgent(FILE *fp)
     +{
 8:  84ca3b10 !  8:  6818c7cf lib/shadow/gshadow/, lib/: sgetsgent(): Move to separate file
    @@ lib/shadow/gshadow/sgetsgent.c (new)
     +static char **build_list(char *s);
     +
     +
    ++// from-string get shadow group entry
     +struct sgrp *
     +sgetsgent(const char *string)
     +{
 9:  13c382c7 !  9:  5803f452 lib/shadow/gshadow/, lib/, src/: getsgnam(): Move to separate file
    @@ lib/shadow/gshadow/getsgnam.c (new)
     + * getsgnam - get a shadow group entry by name
     + */
     +#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
    ++// get shadow group entry-by-name
     +struct sgrp *
     +getsgnam(const char *name)
     +{
10:  b453908b ! 10:  b4391be0 lib/shadow/gshadow/, lib/: getsgent(): Move to separate file
    @@ lib/shadow/gshadow/getsgent.c (new)
     +
     +
     +#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
    -+/*
    -+ * getsgent - get a single shadow group entry
    -+ */
    ++// get-next shadow group entry
     +struct sgrp *
     +getsgent(void)
     +{
11:  bb9fb4cb = 11:  8684b300 lib/: GSHADOW: Remove unused macro
12:  08c1562e ! 12:  bca9fbc3 lib/, po/: sgetgrent(): Move to under lib/shadow/group/
    @@ lib/shadow/group/sgetgrent.c: list(char *s)
      
      
     -struct group *sgetgrent (const char *buf)
    ++// from-string get group entry
     +struct group *
     +sgetgrent(const char *buf)
      {
13:  a5079cb6 ! 13:  9ad790d4 lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/
    @@ lib/sgetpwent.c => lib/shadow/passwd/sgetpwent.c
      /*
       * sgetpwent - convert a string to a (struct passwd)
       *
    +@@
    +  *        performance reasons.  I am going to come up with some conditional
    +  *        compilation glarp to improve on this in the future.
    +  */
    ++// from-string get pasword entry
    + struct passwd *
    + sgetpwent(const char *buf)
    + {
     @@ lib/shadow/passwd/sgetpwent.c: sgetpwent(const char *buf)
      
        return &pwent;
v2b
  • Rebase
$ git range-diff master..gh/shadow shadow/master..shadow
 1:  4777704a =  1:  dab65d54 lib/shadow/gshadow/, lib/: putsgent(): Move to separate file
 2:  1fc9be8a =  2:  533f0178 lib/shadow/gshadow/, lib/: gshadow: Move to separate file and rename
 3:  15cbe6a7 =  3:  b58f9ff0 lib/shadow/gshadow/, lib/, src/: endsgent(): Move to separate file
 4:  5105aeae =  4:  c8b50d36 lib/shadow/gshadow/gshadow.h, lib/, src/: GSHADOW_FILE: Move definition and rename it
 5:  df996ad3 =  5:  a0e09b71 lib/shadow/gshadow/, lib/: setsgent(): Move to separate file
 6:  de18a731 =  6:  1ede63f4 lib/shadow/gshadow/, lib/, src/: struct sgrp: Move to separate file
 7:  694d0ada =  7:  a0a2759f lib/shadow/gshadow/, lib/: fgetsgent(): Move to separate file
 8:  6818c7cf =  8:  b3877b2e lib/shadow/gshadow/, lib/: sgetsgent(): Move to separate file
 9:  5803f452 =  9:  a3eddb96 lib/shadow/gshadow/, lib/, src/: getsgnam(): Move to separate file
10:  b4391be0 = 10:  b1ed4aa9 lib/shadow/gshadow/, lib/: getsgent(): Move to separate file
11:  8684b300 = 11:  a2b77599 lib/: GSHADOW: Remove unused macro
12:  bca9fbc3 = 12:  2d04f252 lib/, po/: sgetgrent(): Move to under lib/shadow/group/
13:  9ad790d4 = 13:  c27bde07 lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/
v2c
  • Rebase
$ git range-diff master..gh/shadow shadow/master..shadow
 1:  dab65d54 =  1:  ed28fd33 lib/shadow/gshadow/, lib/: putsgent(): Move to separate file
 2:  533f0178 =  2:  9ed6e910 lib/shadow/gshadow/, lib/: gshadow: Move to separate file and rename
 3:  b58f9ff0 =  3:  840b6e7d lib/shadow/gshadow/, lib/, src/: endsgent(): Move to separate file
 4:  c8b50d36 =  4:  b513d1ab lib/shadow/gshadow/gshadow.h, lib/, src/: GSHADOW_FILE: Move definition and rename it
 5:  a0e09b71 =  5:  203913cc lib/shadow/gshadow/, lib/: setsgent(): Move to separate file
 6:  1ede63f4 =  6:  6c395e63 lib/shadow/gshadow/, lib/, src/: struct sgrp: Move to separate file
 7:  a0a2759f =  7:  47fbfb56 lib/shadow/gshadow/, lib/: fgetsgent(): Move to separate file
 8:  b3877b2e =  8:  fcecd00d lib/shadow/gshadow/, lib/: sgetsgent(): Move to separate file
 9:  a3eddb96 =  9:  ba24dac1 lib/shadow/gshadow/, lib/, src/: getsgnam(): Move to separate file
10:  b1ed4aa9 = 10:  3648d73f lib/shadow/gshadow/, lib/: getsgent(): Move to separate file
11:  a2b77599 = 11:  70923d56 lib/: GSHADOW: Remove unused macro
12:  2d04f252 = 12:  d52ffeb1 lib/, po/: sgetgrent(): Move to under lib/shadow/group/
13:  c27bde07 = 13:  dd9501d7 lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/

@alejandro-colomar

This comment was marked as outdated.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…on and rename it

Rename it for consistency with the file name itself, and with the FILE*
variable that holds the handle to the open file.

Also, we don't need to wrap it in conditionals.  Just define it
unconditionally, and let it be unused if we don't need it.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
And with it, the file that defines it, which does nothing else.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.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.

None yet

1 participant