Imported Upstream version 20081130
[ltp-debian.git] / testcases / audit-test / trustedprograms / tests / test_useradd.bash
blob4e36c3240b3009e349f34fc59b51bf63804c6ba4
1 #!/bin/bash
2 ###############################################################################
3 # (c) Copyright Hewlett-Packard Development Company, L.P., 2005
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of version 2 the GNU General Public License as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ###############################################################################
18 # PURPOSE:
19 # Verify audit of new user creation, including adding the new user to a group
20 # and creating the new user's home directory.
22 source tp_auth_functions.bash || exit 2
24 # test
25 setpid useradd -n -m -G games -u $uid -d /home/$user $user \
26 || exit_error "useradd failed"
28 for msg_1 in \
29 "op=adding user acct=$user exe=./usr/sbin/useradd.*res=success.*" \
30 "op=adding user to group acct=$user exe=./usr/sbin/useradd.*res=success.*" \
31 "op=adding user to shadow group acct=$user exe=./usr/sbin/useradd.*res=success.*" \
32 "op=adding home directory acct=$user exe=./usr/sbin/useradd.*res=success.*"
34 augrok -q type=USER_CHAUTHTOK \
35 user_pid=$pid \
36 uid=$EUID \
37 auid=$(</proc/self/loginuid) \
38 msg_1=~"$msg_1" || exit_fail "missing: \"$msg_1\""
39 done
41 exit_pass