diff options
author | Diego Elio Pettenò <flameeyes@gentoo.org> | 2005-12-14 19:52:22 +0000 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@gentoo.org> | 2005-12-14 19:52:22 +0000 |
commit | 58d8bb3e7a9776a101a2d8830cfd65ddae44eb4a (patch) | |
tree | d387c1d4c4e4d613edd8cacd44fe61f5a5fc6246 /eclass/portability.eclass | |
parent | Add modular X dependencies. (diff) | |
download | historical-58d8bb3e7a9776a101a2d8830cfd65ddae44eb4a.tar.gz historical-58d8bb3e7a9776a101a2d8830cfd65ddae44eb4a.tar.bz2 historical-58d8bb3e7a9776a101a2d8830cfd65ddae44eb4a.zip |
Added function to get the shell for a given user, and a wrapper function to check if login is disabled for the given user (needed to fix games eclass, see bugzilla).
Diffstat (limited to 'eclass/portability.eclass')
-rw-r--r-- | eclass/portability.eclass | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/eclass/portability.eclass b/eclass/portability.eclass index df39de4119a4..5213b8342fe2 100644 --- a/eclass/portability.eclass +++ b/eclass/portability.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.6 2005/12/14 18:46:50 flameeyes Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.7 2005/12/14 19:52:22 flameeyes Exp $ # # Author: Diego Pettenò <flameeyes@gentoo.org> # @@ -79,6 +79,39 @@ egethome() { esac } +# Gets the shell for the specified user +# it's a wrap around egetent as the position of the home directory in the line +# varies depending on the os used. +# +# To use that, inherit eutils, not portability! +egetshell() { + ent=$(egetent passwd "$1") + + case ${CHOST} in + *-darwin*|*-freebsd*|*-dragonfly*) + # Darwin, OSX, FreeBSD and DragonFly use position 9 to store homedir + cut -d: -f10 <<<${ent} + ;; + *) + # Linux, NetBSD and OpenBSD use position 6 instead + cut -d: -f7 <<<${ent} + ;; + esac +} + +# Returns true if specified user has a shell that precludes logins +# on whichever operating system. +is-login-disabled() { + shell=$(egetshell "$1") + + case ${shell} in + /bin/false|/usr/bin/false|/sbin/nologin|/usr/sbin/nologin) + return 0 ;; + *) + return 1 ;; + esac +} + # Gets the name of the BSD-ish make command (pmake from NetBSD) # # This will return make (provided by system packages) for BSD userlands, |