pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/40737: bad flag in useradd for Linux



The following reply was made to PR pkg/40737; it has been noted by GNATS.

From: Joerg Sonnenberger <joerg%britannica.bec.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: pkg-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, 
pkgsrc-bugs%netbsd.org@localhost,
        aniou%smutek.pl@localhost
Subject: Re: pkg/40737: bad flag in useradd for Linux
Date: Thu, 26 Feb 2009 18:11:20 +0100

 --6c2NcOVqGQ03X4Wi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Thu, Feb 26, 2009 at 10:10:05AM +0000, Piotr Meyer wrote:
 >  Patch in attachment and under following link:
 >  http://aniou.smutek.pl/useradd-for-linux.diff
 
 That is one of the options. Attached is what I have in mind --
 it should work for the default installations on the various systems
 and only fail if the user manually enabled CREATE_HOME on a system
 without support for -M, but in that case failing is somewhat sensible an
 option.
 
 Joerg
 
 --6c2NcOVqGQ03X4Wi
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="usergroupfuncs.Linux.diff"
 
 Index: usergroupfuncs.Linux
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/mk/pkginstall/usergroupfuncs.Linux,v
 retrieving revision 1.4
 diff -u -p -r1.4 usergroupfuncs.Linux
 --- usergroupfuncs.Linux       2 Feb 2009 19:54:22 -0000       1.4
 +++ usergroupfuncs.Linux       26 Feb 2009 17:11:07 -0000
 @@ -83,6 +83,30 @@ user_exists()
        ${RM} -fr $_tmpdir; return 3
  }
  
 +# The useradd command on Linux is a complete mess.
 +# At least Red Hat derivatives want to create home directories
 +# by default. They have support for -M, but no --help.
 +# Other Linux distributions lack -M support, some at least have
 +# --help.
 +# LSB just wants useradd, but doesn't specify any behavior, so
 +# it is useless for writing portable scripts.
 +
 +call_useradd()
 +{
 +      case $userid in
 +      "")
 +              ${USERADD}                                      \
 +                      -c "$descr" -d "$home" -s "$shell"      \
 +                      -g $group $user "$@"
 +              ;;
 +      *)
 +              ${USERADD}                                      \
 +                      -c "$descr" -d "$home" -s "$shell"      \
 +                      -g $group -u $userid $user "$@"
 +              ;;
 +      esac
 +}
 +
  # adduser user group [userid] [descr] [home] [shell]
  adduser()
  {
 @@ -104,18 +128,11 @@ adduser()
  
        if ${TEST} -n "${USERADD}" -a -x "${USERADD}"; then
                ${ECHO} "${PKGNAME}: Creating user \`\`$user''"
 -              case $userid in
 -              "")
 -                      ${USERADD}                                      \
 -                              -c "$descr" -d "$home" -s "$shell"      \
 -                              -g $group $user -M
 -                      ;;
 -              *)
 -                      ${USERADD}                                      \
 -                              -c "$descr" -d "$home" -s "$shell"      \
 -                              -g $group -u $userid $user -M
 -                      ;;
 -              esac
 +              if grep -i -- "^CREATE_HOME.*yes" /etc/login.defs > /dev/null; 
then
 +                      call_useradd -M
 +              else
 +                      call_useradd
 +              fi
        fi
        return 0
  }
 
 --6c2NcOVqGQ03X4Wi--
 


Home | Main Index | Thread Index | Old Index