Remove POSIX users.

This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2015-07-13 19:50:58 +05:30
1 parent d672e24ac4
commit 2adf14b8b7
14 files changed
+15 -327

No files matched your search

-34
View File
@@ -1,34 +0,0 @@
#!/bin/bash
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Must be run as root.
username="$1"
password="$2"
getent passwd "$username"
if [ $? -ne 0 ]; then
echo "Failed: user not found"
exit
fi
echo "$username:$password" | chpasswd
if [ $? -ne 0 ]; then
echo "Failed: could not set user password"
exit 2
fi
-28
View File
@@ -1,28 +0,0 @@
#!/bin/sh
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Can be run as normal user.
username="$1"
getent passwd "$username" >/dev/null
if [ $? -eq 0 ]; then
echo "User exists"
else
echo "User does not exist"
fi
+7 -2
View File
@@ -30,6 +30,11 @@ cn: $username
userPassword: $password
EOF
if [ $? -ne 0 ]; then
echo "Failed to create user"
exit 1
fi
uid_num=$(getent passwd | awk -F: '($3>=1000) && ($3<59999) && ($3>maxuid) { maxuid=$3; } END { print maxuid+1; }')
home_dir=/home/$username
@@ -50,8 +55,8 @@ homeDirectory: $home_dir
EOF
if [ $? -ne 0 ]; then
echo "Failed to create user"
exit 1
echo "Failed to create posix account for user"
exit 2
fi
# check if admin group exists
-38
View File
@@ -1,38 +0,0 @@
#!/bin/bash
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
username="$1"
password="$2"
adduser --disabled-password --gecos "" "$username"
if [ $? -ne 0 ]; then
echo "Failed to create user"
exit 1
fi
adduser "$username" sudo
if [ $? -ne 0 ]; then
echo "Failed to add user to sudo group"
exit 2
fi
echo "$username:$password" | chpasswd
if [ $? -ne 0 ]; then
echo "Failed to set user password"
exit 3
fi
-35
View File
@@ -1,35 +0,0 @@
#!/bin/sh
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Must be run as root.
username="$1"
getent passwd "$username"
if [ $? -ne 0 ]; then
echo "Failed: user not found"
exit
fi
deluser "$username"
if [ $? -eq 0 ]; then
echo "Success: user deleted"
else
echo "Failed: userdel error"
exit 2
fi
-33
View File
@@ -1,33 +0,0 @@
#!/bin/sh
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Must be run as root.
username="$1"
getent passwd "$username"
if [ $? -ne 0 ]; then
echo "Failed: user not found"
exit
fi
usermod --expiredate 1 "$username"
if [ $? -ne 0 ]; then
echo "Failed"
exit 2
fi
-33
View File
@@ -1,33 +0,0 @@
#!/bin/sh
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Must be run as root.
username="$1"
getent passwd "$username"
if [ $? -ne 0 ]; then
echo "Failed: user not found"
exit
fi
usermod --expiredate "" "$username"
if [ $? -ne 0 ]; then
echo "Failed"
exit 2
fi
-36
View File
@@ -1,36 +0,0 @@
#!/bin/sh
#
# This file is part of Plinth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Must be run as root.
old_username="$1"
new_username="$2"
getent passwd "$old_username"
if [ $? -ne 0 ]; then
echo "Failed: user not found"
exit
fi
usermod -l "$new_username" "$old_username"
if [ $? -eq 0 ]; then
echo "Success: user renamed"
else
echo "Failed: user rename failed"
exit 2
fi