Imported Upstream version 20081130
[ltp-debian.git] / testcases / audit-test / trustedprograms / tests / test_usermod_g.bash
blob5158bdfe2785f84ddac9d4f2bd2b0656e9ff4e99
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 changes to a user's default group.
21 source tp_auth_functions.bash || exit 2
23 # setup
24 useradd -n -u $uid $user || exit_error "useradd failed"
25 read group2 gid2 <<<"$(generate_unique_group)"
26 groupadd -g $gid2 $group2 || exit_error "groupadd failed"
28 prepend_cleanup "grep -q '^$group2:' /etc/group && groupdel '$group2'"
30 # test
31 setpid usermod -g $gid2 $user || exit_error "usermod failed"
33 for msg_1 in \
34 "op=changing primary group acct=$user exe=./usr/sbin/usermod.*res=success.*"
36 augrok -q type=USER_CHAUTHTOK \
37 user_pid=$pid \
38 uid=$EUID \
39 auid=$(</proc/self/loginuid) \
40 msg_1=~"$msg_1" || exit_fail "missing: \"$msg_1\""
41 done
43 exit_pass