mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Remove POSIX users.
This commit is contained in:
1 parent
d672e24ac4
commit
2adf14b8b7
14 files changed
+15
-327
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user