Open
Description
Hi!
We've recently discovered your project and related comment. It looks very promising, but we've encountered some problems: we can not correctly create users and groups in systemdb. All created users and groups are actually missing in /etc/passwd and /etc/group and even deleting of previous created users doesn't work fine.
Could you please provide any examples that will add the user to the system db with a command like adduser
All our configs are below
/etc/libnss_shim/config.json
{
"databases": {
"group": {
"functions": {
"get_entry_by_gid": {
"command": "/usr/local/bin/group_get_all_entries.sh -g <$gid>"
},
"get_entry_by_name": {
"command": "/usr/local/bin/group_get_all_entries.sh -n <$name>"
}
}
},
"passwd": {
"functions": {
"get_entry_by_name": {
"command": "/usr/local/bin/passwd_get_all_entries.sh -n <$name>"
},
"get_entry_by_uid": {
"command": "/usr/local/bin/passwd_get_all_entries.sh -u <$uid>"
}
}
},
"shadow": {
"functions": {
"get_entry_by_name": {
"command": "/bin/bash -c \"echo $name:*:19156:0:99999:7:::\""
}
}
}
},
"debug": true
}
/usr/local/bin/passwd_get_all_entries.sh
#!/bin/bash
# https://serverfault.com/questions/1122226/user-account-auto-creation-using-ssh-certificate-authentication
if [ $# -eq 0 ]; then
exit 0
fi
while getopts "u:n:" opt; do
case $opt in
u)
uid=$OPTARG
name=$(find /home -maxdepth 1 -type d -uid $uid | head -1 | cut -d "/" -f 3)
echo "$name:x:$uid:1::/home/$name:/bin/bash"
;;
n)
name=$OPTARG
uid=$(stat -c %u /home/$name 2>/dev/null)
if [[ -z $uid ]]; then
uid=$(stat -c %u /home/* | sort | tail -1 | awk '{print $1+1;}')
fi
sudo_gid=27
echo "$name:x:$uid:$uid::/home/$name:/bin/bash"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
/usr/local/bin/group_get_all_entries.sh
#!/bin/bash
# https://serverfault.com/questions/1122226/user-account-auto-creation-using-ssh-certificate-authentication
if [ $# -eq 0 ]; then
exit 0
fi
while getopts "g:n:" opt; do
case $opt in
g)
uid=$OPTARG
name=$(find /home -maxdepth 1 -type d -uid $uid | head -1 | cut -d "/" -f 3)
echo "$name:x:$uid:"
;;
n)
name=$OPTARG
uid=$(stat -c %u /home/$name 2>/dev/null)
if [[ -z $uid ]]; then
uid=$(stat -c %u /home/* | sort | tail -1 | awk '{print $1+1;}')
fi
echo "$name:x:$uid:"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
/etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: files systemd shim
group: files systemd shim
shadow: files shim
gshadow: files
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
root@testhost:~# useradd test1
useradd: user 'test1' already exists
root@testhost:~# groupadd mygrp
groupadd: group 'mygrp' already exists
root@testhost:~# grep mygrp /etc/group
root@testhost:~# grep test /etc/passwd
root@testhost:~#
Metadata
Metadata
Assignees
Labels
No labels