Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-admin/superadduser/files/1.15/, app-admin/superadduser/
Date: Fri, 31 Aug 2018 03:06:31
Message-Id: 1535684751.eaeda9f2a772c631618040c09b2206b008024df2.whissi@gentoo
1 commit: eaeda9f2a772c631618040c09b2206b008024df2
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 31 03:05:51 2018 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 31 03:05:51 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eaeda9f2
7
8 app-admin/superadduser: bump to v1.15
9
10 Package-Manager: Portage-2.3.48, Repoman-2.3.10
11
12 app-admin/superadduser/files/1.15/superadduser | 445 ++++++++++++++++++++++++
13 app-admin/superadduser/superadduser-1.15.ebuild | 22 ++
14 2 files changed, 467 insertions(+)
15
16 diff --git a/app-admin/superadduser/files/1.15/superadduser b/app-admin/superadduser/files/1.15/superadduser
17 new file mode 100644
18 index 00000000000..ce06aac5409
19 --- /dev/null
20 +++ b/app-admin/superadduser/files/1.15/superadduser
21 @@ -0,0 +1,445 @@
22 +#!/bin/bash
23 +#
24 +# Copyright 1995 Hrvoje Dogan, Croatia.
25 +# Copyright 2002-2004, 2008, 2009, 2010 Stuart Winter, Surrey, England, UK.
26 +# Copyright 2004, 2008-2010 Slackware Linux, Inc., Concord, CA, USA
27 +# Copyright 2012 Patrick J. Volkerding, Sebeka, MN, USA
28 +# All rights reserved.
29 +#
30 +# Redistribution and use of this script, with or without modification, is
31 +# permitted provided that the following conditions are met:
32 +#
33 +# 1. Redistributions of this script must retain the above copyright
34 +# notice, this list of conditions and the following disclaimer.
35 +#
36 +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
37 +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
38 +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
39 +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
41 +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
42 +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
43 +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
44 +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
45 +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 +#
47 +#
48 +##########################################################################
49 +# Program: /usr/sbin/adduser
50 +# Purpose: Interactive front end to /usr/sbin/useradd for Slackware Linux
51 +# Author : Stuart Winter <mozes@×××××××××.com>
52 +# Based on the original Slackware adduser by Hrvoje Dogan
53 +# with modifications by Patrick Volkerding
54 +# Version: 1.15
55 +##########################################################################
56 +# Usage..: adduser [<new_user_name>]
57 +##########################################################################
58 +# History #
59 +###########
60 +# v1.15 - 2012-09-13
61 +# * Added scanner group, which may be required by third party drivers.
62 +# v1.14 - 2012-08-24
63 +# * Added lp group, which is now required for scanning. <pjv>
64 +# v1.13 - 13/01/10
65 +# * Fixed bug that removed underscore characters from UNIX group names.
66 +# Thanks to mRgOBLIN for the report and Jim Hawkins for the fix. <sw>
67 +# v1.12 - 21/07/09
68 +# * Adjusted the search of /etc/passwd to exclude the NIS inclusion
69 +# string. Thanks to Dominik L. Borkowski.
70 +# v1.11 - 04/06/09
71 +# * Add power and netdev to the suggested group list
72 +# v1.10 - 24/03/08
73 +# * To facilitate use of the automatic mounting features of HAL,
74 +# allow the admin to easily add users to the default groups:
75 +# audio,cdrom,video,plugdev,floppy.
76 +# The default is not to add new users to these groups.
77 +# And by the way, this script is "useradd from Slackware" not
78 +# "superadduser from Gentoo" ;-)
79 +# v1.09 - 07/06/04
80 +# * Added standard Slackware script licence to the head of this file.
81 +# v1.08 - 25/04/04
82 +# * Disallow user names that begin with a numeric because useradd
83 +# (from shadow v4.03) does not allow them. <sw>
84 +# v1.07 - 07/03/03
85 +# * When supplying a null string for the uid (meaning 'Choose next available'),
86 +# if there were file names in the range 'a-z' in the pwd then the
87 +# egrep command considered these files rather than the null string.
88 +# The egrep expression is now in quotes.
89 +# Reported & fixed by Vadim O. Ustiansky <sw>
90 +# v1.06 - 31/03/03
91 +# * Ask to chown user.group the home directory if it already exists.
92 +# This helps reduce later confusion when adding users whose home dir
93 +# already exists (mounted partition for example) and is owned
94 +# by a user other than the user to which the directory is being
95 +# assigned as home. Default is not to chown.
96 +# Brought to my attention by mRgOBLIN. <sw>
97 +# v1.05 - 04/01/03
98 +# * Advise & prevent users from creating logins with '.' characters
99 +# in the user name. <sw>
100 +# * Made pending account creation info look neater <sw>
101 +# v1.04 - 09/06/02
102 +# * Catered for shadow-4.0.3's 'useradd' binary that no longer
103 +# will let you create a user that has any uppercase chars in it
104 +# This was reported on the userlocal.org forums
105 +# by 'xcp' - thanks. <sw,pjv>
106 +# v1.03 - 20/05/02
107 +# * Support 'broken' (null lines in) /etc/passwd and
108 +# /etc/group files <sw>
109 +# * For recycling UIDs (default still 'off'), we now look in
110 +# /etc/login.defs for the UID_MIN value and use it
111 +# If not found then default to 1000 <sw>
112 +# v1.02 - 10/04/02
113 +# * Fix user-specified UID bug. <pjv>
114 +# v1.01 - 23/03/02
115 +# * Match Slackware indenting style, simplify. <pjv>
116 +# v1.00 - 22/03/02
117 +# * Created
118 +#######################################################################
119 +
120 +# Path to files
121 +pfile=/etc/passwd
122 +gfile=/etc/group
123 +sfile=/etc/shells
124 +
125 +# Paths to binaries
126 +useradd=/usr/sbin/useradd
127 +chfn=/usr/bin/chfn
128 +passwd=/usr/bin/passwd
129 +chmod=/bin/chmod
130 +
131 +# Defaults
132 +defhome=/home
133 +defshell=/bin/bash
134 +defchmod=711 # home dir permissions - may be preferable to use 701, however.
135 +defgroup=users
136 +AGID="audio cdrom floppy plugdev video power netdev lp scanner" # additional groups for desktop users
137 +
138 +# Determine what the minimum UID is (for UID recycling)
139 +# (we ignore it if it's not at the beginning of the line (i.e. commented out with #))
140 +export recycleUIDMIN="$(grep ^UID_MIN /etc/login.defs | awk '{print $2}' 2>/dev/null)"
141 +# If we couldn't find it, set it to the default of 1000
142 +if [ -z "$recycleUIDMIN" ]; then
143 + export recycleUIDMIN=1000 # this is the default from Slackware's /etc/login.defs
144 +fi
145 +
146 +
147 +# This setting enables the 'recycling' of older unused UIDs.
148 +# When you userdel a user, it removes it from passwd and shadow but it will
149 +# never get used again unless you specify it expliticly -- useradd (appears to) just
150 +# look at the last line in passwd and increment the uid. I like the idea of
151 +# recycling uids but you may have very good reasons not to (old forgotten
152 +# confidential files still on the system could then be owned by this new user).
153 +# We'll set this to no because this is what the original adduser shell script
154 +# did and it's what users expect.
155 +recycleuids=no
156 +
157 +# Function to read keyboard input.
158 +# bash1 is broken (even ash will take read -ep!), so we work around
159 +# it (even though bash1 is no longer supported on Slackware).
160 +function get_input() {
161 + local output
162 + if [ "`echo $BASH_VERSION | cut -b1`" = "1" ]; then
163 + echo -n "${1} " >&2 # fudge for use with bash v1
164 + read output
165 + else # this should work with any other /bin/sh
166 + read -ep "${1} " output
167 + fi
168 + echo $output
169 +}
170 +
171 +# Function to display the account info
172 +function display () {
173 + local goose
174 + goose="$(echo $2 | cut -d ' ' -f 2-)" # lop off the prefixed argument useradd needs
175 + echo -n "$1 "
176 + # If it's null then display the 'other' information
177 + if [ -z "$goose" -a ! -z "$3" ]; then
178 + echo "$3"
179 + else
180 + echo "$goose"
181 + fi
182 +}
183 +
184 +# Function to check whether groups exist in the /etc/group file
185 +function check_group () {
186 + local got_error group
187 + if [ ! -z "$@" ]; then
188 + for group in $@ ; do
189 + local uid_not_named="" uid_not_num=""
190 + grep -v "$^" $gfile | awk -F: '{print $1}' | grep "^${group}$" >/dev/null 2>&1 || uid_not_named=yes
191 + grep -v "$^" $gfile | awk -F: '{print $3}' | grep "^${group}$" >/dev/null 2>&1 || uid_not_num=yes
192 + if [ ! -z "$uid_not_named" -a ! -z "$uid_not_num" ]; then
193 + echo "- Group '$group' does not exist"
194 + got_error=yes
195 + fi
196 + done
197 + fi
198 + # Return exit code of 1 if at least one of the groups didn't exist
199 + if [ ! -z "$got_error" ]; then
200 + return 1
201 + fi
202 +}
203 +
204 +#: Read the login name for the new user :#
205 +#
206 +# Remember that most Mail Transfer Agents are case independant, so having
207 +# 'uSer' and 'user' may cause confusion/things to break. Because of this,
208 +# useradd from shadow-4.0.3 no longer accepts usernames containing uppercase,
209 +# and we must reject them, too.
210 +
211 +# Set the login variable to the command line param
212 +echo
213 +LOGIN="$1"
214 +needinput=yes
215 +while [ ! -z $needinput ]; do
216 + if [ -z "$LOGIN" ]; then
217 + while [ -z "$LOGIN" ]; do LOGIN="$(get_input "Login name for new user []:")" ; done
218 + fi
219 + grep "^${LOGIN}:" $pfile >/dev/null 2>&1 # ensure it's not already used
220 + if [ $? -eq 0 ]; then
221 + echo "- User '$LOGIN' already exists; please choose another"
222 + unset LOGIN
223 + elif [ ! -z "$( echo $LOGIN | grep "^[0-9]" )" ]; then
224 + echo "- User names cannot begin with a number; please choose another"
225 + unset LOGIN
226 + elif [ ! "$LOGIN" = "`echo $LOGIN | tr A-Z a-z`" ]; then # useradd does not allow uppercase
227 + echo "- User '$LOGIN' contains illegal characters (uppercase); please choose another"
228 + unset LOGIN
229 + elif [ ! -z "$( echo $LOGIN | grep '\.' )" ]; then
230 + echo "- User '$LOGIN' contains illegal characters (period/dot); please choose another"
231 + unset LOGIN
232 + else
233 + unset needinput
234 + fi
235 +done
236 +
237 +# Display the user name passed from the shell if it hasn't changed
238 +if [ "$1" = "$LOGIN" ]; then
239 + echo "Login name for new user: $LOGIN"
240 +fi
241 +
242 +#: Get the UID for the user & ensure it's not already in use :#
243 +#
244 +# Whilst we _can_ allow users with identical UIDs, it's not a 'good thing' because
245 +# when you change password for the uid, it finds the first match in /etc/passwd
246 +# which isn't necessarily the correct user
247 +#
248 +echo
249 +needinput=yes
250 +while [ ! -z "$needinput" ]; do
251 + _UID="$(get_input "User ID ('UID') [ defaults to next available ]:")"
252 + egrep -v "^$|^\+" $pfile | awk -F: '{print $3}' | grep "^${_UID}$" >/dev/null 2>&1
253 + if [ $? -eq 0 ]; then
254 + echo "- That UID is already in use; please choose another"
255 + elif [ ! -z "$(echo $_UID | egrep '[A-Za-z]')" ]; then
256 + echo "- UIDs are numerics only"
257 + else
258 + unset needinput
259 + fi
260 +done
261 +# If we were given a UID, then syntax up the variable to pass to useradd
262 +if [ ! -z "$_UID" ]; then
263 + U_ID="-u ${_UID}"
264 +else
265 + # Will we be recycling UIDs?
266 + if [ "$recycleuids" = "yes" ]; then
267 + U_ID="-u $(awk -F: '{uid[$3]=1} END { for (i=ENVIRON["recycleUIDMIN"];i in uid;i++);print i}' $pfile)"
268 + fi
269 +fi
270 +
271 +#: Get the initial group for the user & ensure it exists :#
272 +#
273 +# We check /etc/group for both the text version and the group ID number
274 +echo
275 +needinput=yes
276 +while [ ! -z "$needinput" ]; do
277 + GID="$(get_input "Initial group [ ${defgroup} ]:")"
278 + check_group "$GID"
279 + if [ $? -gt 0 ]; then
280 + echo "- Please choose another"
281 + else
282 + unset needinput
283 + fi
284 +done
285 +# Syntax the variable ready for useradd
286 +if [ -z "$GID" ]; then
287 + GID="-g ${defgroup}"
288 +else
289 + GID="-g ${GID}"
290 +fi
291 +
292 +#: Get additional groups for the user :#
293 +#
294 +echo "Additional UNIX groups:"
295 +echo
296 +echo "Users can belong to additional UNIX groups on the system."
297 +echo "For local users using graphical desktop login managers such"
298 +echo "as XDM/KDM, users may need to be members of additional groups"
299 +echo "to access the full functionality of removable media devices."
300 +echo
301 +echo "* Security implications *"
302 +echo "Please be aware that by adding users to additional groups may"
303 +echo "potentially give access to the removable media of other users."
304 +echo
305 +echo "If you are creating a new user for remote shell access only,"
306 +echo "users do not need to belong to any additional groups as standard,"
307 +echo "so you may press ENTER at the next prompt."
308 +echo
309 +needinput=yes
310 +while [ ! -z "$needinput" ]; do
311 + history -c
312 + history -s "$AGID"
313 + echo "Press ENTER to continue without adding any additional groups"
314 + echo "Or press the UP arrow key to add/select/edit additional groups"
315 + AGID="$(get_input ": " | sed 's/[^A-Za-z0-9 _]//g;s/ */ /g;s/^ $//g' )"
316 + if [ ! -z "$AGID" ]; then
317 + check_group "$AGID" # check all groups at once (treated as N # of params)
318 + if [ $? -gt 0 ]; then
319 + echo "- Please re-enter the group(s)"
320 + echo
321 + else
322 + unset needinput # we found all groups specified
323 + AGID="-G $(echo $AGID | tr ' ' ,)" # useradd takes comma delimited groups
324 + fi
325 + else
326 + unset needinput # we don't *have* to have additional groups
327 + fi
328 +done
329 +
330 +#: Get the new user's home dir :#
331 +#
332 +echo
333 +needinput=yes
334 +while [ ! -z "$needinput" ]; do
335 + HME="$(get_input "Home directory [ ${defhome}/${LOGIN} ]")"
336 + if [ -z "$HME" ]; then
337 + HME="${defhome}/${LOGIN}"
338 + fi
339 + # Warn the user if the home dir already exists
340 + if [ -d "$HME" ]; then
341 + echo "- Warning: '$HME' already exists !"
342 + getyn="$(get_input " Do you wish to change the home directory path ? (Y/n) ")"
343 + if [ "$(echo $getyn | grep -i "n")" ]; then
344 + unset needinput
345 + # You're most likely going to only do this if you have the dir *mounted* for this user's $HOME
346 + getyn="$(get_input " Do you want to chown $LOGIN.$( echo $GID | awk '{print $2}') $HME ? (y/N) ")"
347 + if [ "$(echo $getyn | grep -i "y")" ]; then
348 + CHOWNHOMEDIR=$HME # set this to the home directory
349 + fi
350 + fi
351 + else
352 + unset needinput
353 + fi
354 +done
355 +HME="-d ${HME}"
356 +
357 +#: Get the new user's shell :#
358 +echo
359 +needinput=yes
360 +while [ ! -z "$needinput" ]; do
361 + unset got_error
362 + SHL="$(get_input "Shell [ ${defshell} ]")"
363 + if [ -z "$SHL" ]; then
364 + SHL="${defshell}"
365 + fi
366 + # Warn the user if the shell doesn't exist in /etc/shells or as a file
367 + if [ -z "$(grep "^${SHL}$" $sfile)" ]; then
368 + echo "- Warning: ${SHL} is not in ${sfile} (potential problem using FTP)"
369 + got_error=yes
370 + fi
371 + if [ ! -f "$SHL" ]; then
372 + echo "- Warning: ${SHL} does not exist as a file"
373 + got_error=yes
374 + fi
375 + if [ ! -z "$got_error" ]; then
376 + getyn="$(get_input " Do you wish to change the shell ? (Y/n) ")"
377 + if [ "$(echo $getyn | grep -i "n")" ]; then
378 + unset needinput
379 + fi
380 + else
381 + unset needinput
382 + fi
383 +done
384 +SHL="-s ${SHL}"
385 +
386 +#: Get the expiry date :#
387 +echo
388 +needinput=yes
389 +while [ ! -z "$needinput" ]; do
390 + EXP="$(get_input "Expiry date (YYYY-MM-DD) []:")"
391 + if [ ! -z "$EXP" ]; then
392 + # Check to see whether the expiry date is in the valid format
393 + if [ -z "$(echo "$EXP" | grep "^[[:digit:]]\{4\}[-]\?[[:digit:]]\{2\}[-]\?[[:digit:]]\{2\}$")" ]; then
394 + echo "- That is not a valid expiration date"
395 + else
396 + unset needinput
397 + EXP="-e ${EXP}"
398 + fi
399 + else
400 + unset needinput
401 + fi
402 +done
403 +
404 +# Display the info about the new impending account
405 +echo
406 +echo "New account will be created as follows:"
407 +echo
408 +echo "---------------------------------------"
409 +display "Login name.......: " "$LOGIN"
410 +display "UID..............: " "$_UID" "[ Next available ]"
411 +display "Initial group....: " "$GID"
412 +display "Additional groups: " "$AGID" "[ None ]"
413 +display "Home directory...: " "$HME"
414 +display "Shell............: " "$SHL"
415 +display "Expiry date......: " "$EXP" "[ Never ]"
416 +echo
417 +
418 +echo "This is it... if you want to bail out, hit Control-C. Otherwise, press"
419 +echo "ENTER to go ahead and make the account."
420 +read junk
421 +
422 +echo
423 +echo "Creating new account..."
424 +echo
425 +echo
426 +
427 +# Add the account to the system
428 +CMD="$useradd "$HME" -m "$EXP" "$U_ID" "$GID" "$AGID" "$SHL" "$LOGIN""
429 +$CMD
430 +
431 +if [ $? -gt 0 ]; then
432 + echo "- Error running useradd command -- account not created!"
433 + echo "(cmd: $CMD)"
434 + exit 1
435 +fi
436 +
437 +# chown the home dir ? We can only do this once the useradd has
438 +# completed otherwise the user name doesn't exist.
439 +if [ ! -z "${CHOWNHOMEDIR}" ]; then
440 + chown "$LOGIN"."$( echo $GID | awk '{print $2}')" "${CHOWNHOMEDIR}"
441 +fi
442 +
443 +# Set the finger information
444 +$chfn "$LOGIN"
445 +if [ $? -gt 0 ]; then
446 + echo "- Warning: an error occurred while setting finger information"
447 +fi
448 +
449 +# Set a password
450 +$passwd "$LOGIN"
451 +if [ $? -gt 0 ]; then
452 + echo "* WARNING: An error occured while setting the password for"
453 + echo " this account. Please manually investigate this *"
454 + exit 1
455 +fi
456 +
457 +# If it was created (it should have been!), set the permissions for that user's dir
458 +HME="$(echo "$HME" | awk '{print $2}')" # We have to remove the -g prefix
459 +if [ -d "$HME" ]; then
460 + $chmod $defchmod "$HME"
461 +fi
462 +
463 +echo
464 +echo
465 +echo "Account setup complete."
466 +exit 0
467
468 diff --git a/app-admin/superadduser/superadduser-1.15.ebuild b/app-admin/superadduser/superadduser-1.15.ebuild
469 new file mode 100644
470 index 00000000000..78ba0682ff0
471 --- /dev/null
472 +++ b/app-admin/superadduser/superadduser-1.15.ebuild
473 @@ -0,0 +1,22 @@
474 +# Copyright 1999-2018 Gentoo Foundation
475 +# Distributed under the terms of the GNU General Public License v2
476 +
477 +EAPI="6"
478 +
479 +DESCRIPTION="Interactive adduser script from Slackware"
480 +HOMEPAGE="http://www.interlude.org.uk/unix/slackware/"
481 +SRC_URI=""
482 +
483 +LICENSE="BSD"
484 +SLOT="0"
485 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
486 +IUSE=""
487 +
488 +RDEPEND="sys-apps/shadow"
489 +
490 +S=${WORKDIR}
491 +
492 +src_install() {
493 + dosbin "${FILESDIR}"/${PV}/superadduser
494 + doman "${FILESDIR}"/superadduser.8
495 +}