From: Thomas Walker Lynch Date: Sat, 5 Mar 2022 22:36:58 +0000 (-0500) Subject: subu_add subu_del X-Git-Url: https://git.reasoningtechnology.com/style/static/git-favicon.png?a=commitdiff_plain;h=8acc3f25fec3d94ab230aad0b347637c538e366e;p=subu subu_add subu_del --- diff --git a/exec/subu_add b/exec/subu_add new file mode 100755 index 0000000..abd732e --- /dev/null +++ b/exec/subu_add @@ -0,0 +1,35 @@ +#!/bin/bash +# must have commands rsync and user-stem +# user-stem is in the system repo +# +# wish we could set the uids and gids so that backups would restore properly on other systems but it is too much trouble +# to do in a shell script. Perhaps in the python code for the actual release. + +subu=$1 + + +if [ ! -x "/usr/local/bin/user-stem" ]; then + echo "no /usr/local/bin/user-stem program found (it is in the system repo)" + exit 1 +fi + +if [ -z "$subu" ]; then + echo "no subuser name supplied" + exit 1 +fi + +# stem includes all characters up to the first '-' +stem=$(/usr/local/bin/user-stem) + +user_subu="$stem-$subu" +user_admin="$stem-admin" + +home_subu="/home/$stem/$subu" +home_admin="/home/$stem/admin" + +sudo useradd --home-dir "$home_subu" "$user_subu" +sudo usermod -aG "$user_subu" "$user_admin" +sudo find "$home_admin/subu_default" -mindepth 1 -execdir cp -p {} "$home_subu" \; +sudo find "$home_subu" -execdir chown "$user_subu":"$user_subu" {} \; + + diff --git a/exec/subu_del b/exec/subu_del new file mode 100755 index 0000000..2a9e474 --- /dev/null +++ b/exec/subu_del @@ -0,0 +1,63 @@ +#!/bin/bash +# must have command user-stem +# user-stem is in the system repo +# +# currently this is setup to be run by any user who has sudo - it doesn't have to be run by the user-admin account; though chances are it will be. +# +# userdel -r deletes both the /var/spool/mail/user and the user's home directory. We don't want to delete the old data just in case there +# is something important there. However we can not leve the old /var/spool/mail/user file under /var/spool/mail in case another subu is +# created later with the same name. Hence we will move the /var/spool/mail/user file into the users home directory. We will give ownership +# of the old home directory to the admin. +# +# I have run into a problem that subu users do not inherit the MAIL variable, I wouldn't trust it anyway. I do not know if userdel -r +# references the MAIL variable. I will hard code a local variable to /var/sppol/mail. This must be changed for systems that put the mail spool +# file eleswhere. +# +#set -x + +subu=$1 + +if [ ! -x "/usr/local/bin/user-stem" ]; then + echo "no /usr/local/bin/user-stem program found (it is in the system repo)" + exit 1 +fi + +if [ -z "$subu" ]; then + echo "no subuser name supplied" + exit 1 +fi + +# stem includes all characters up to the first '-' +stem=$(/usr/local/bin/user-stem) +user_subu="$stem-$subu" +user_admin="$stem-admin" +home_subu="/home/$stem/$subu" +archive_suffix=_former_subu +archive_subu="$home_subu$archive_suffix" +mail_source_dir="/var/spool/mail" +mail_source_file="$mail_source_dir/$user_subu" +mail_target_file="$home_subu/mail_spool" + +if [ -e "$archive_subu" ]; then + echo "there is already a saved directory for a deleted subu with this name, move this out of the way first: $archive_subu" + exit 1 +fi +if [ ! -d "$mail_source_dir" ]; then + echo "could not find mail spooler directory: $mail_source_dir" + exit 1 +fi + +if [ -e "$mail_target_file" ]; then + echo "there is already file system object where we planned to move the deleted user's mail spool, which is here: $home_subu/mail_spool" + exit 1 +fi + +sudo killall --signal 5 --user "$user_subu" +sudo mv "$mail_source_file" "$mail_target_file" +sudo chmod -R go-rwx "$home_subu" +sudo chown -R "$user_admin":"$user_admin" "$home_subu" +mv "$home_subu" "$archive_subu" +sudo groupdel -f "$user_subu" +sudo userdel "$user_subu" + +#set +x diff --git a/try/sss_cache_probs/dbprintf.aux.o b/try/sss_cache_probs/dbprintf.aux.o deleted file mode 100644 index 0b30dab..0000000 Binary files a/try/sss_cache_probs/dbprintf.aux.o and /dev/null differ diff --git a/try/sss_cache_probs/dispatch.lib.o b/try/sss_cache_probs/dispatch.lib.o deleted file mode 100644 index a6a471a..0000000 Binary files a/try/sss_cache_probs/dispatch.lib.o and /dev/null differ diff --git a/try/sss_cache_probs/sss_cache b/try/sss_cache_probs/sss_cache deleted file mode 100755 index 39fd5b8..0000000 Binary files a/try/sss_cache_probs/sss_cache and /dev/null differ diff --git a/try/sss_cache_probs/sss_cache.cli.o b/try/sss_cache_probs/sss_cache.cli.o deleted file mode 100644 index 16f9c8f..0000000 Binary files a/try/sss_cache_probs/sss_cache.cli.o and /dev/null differ diff --git a/try/sss_cache_probs/sss_cache.lib.o b/try/sss_cache_probs/sss_cache.lib.o deleted file mode 100644 index 97c8584..0000000 Binary files a/try/sss_cache_probs/sss_cache.lib.o and /dev/null differ