change example

This commit is contained in:
quackerd 2021-02-19 18:26:08 -05:00
parent 1308f89d08
commit 1f4114160d
Signed by: d
GPG Key ID: F73412644EDE357A

View File

@ -3,6 +3,7 @@
import os
import sys
import subprocess
import shlex
def main():
if (len(sys.argv) < 3):
@ -18,7 +19,7 @@ def main():
if (len(elements) != 2):
print("Skipping invalid group config string \"" + group + "\"")
continue
subprocess.check_call("addgroup -g " + elements[1] + " " + elements[0], shell=True)
subprocess.check_call(shlex.join(["addgroup", "-g", elements[1], elements[0]]), shell=True)
print("Added group " + elements[0] + " with gid " + elements[1])
@ -28,13 +29,13 @@ def main():
if (len(elements) != 3 and len(elements) != 4):
print("Skipping invalid user config string \"" + user + "\"")
continue
subprocess.check_call("adduser -D -H -u " + elements[1] + " " + elements[0], shell=True)
subprocess.check_call(shlex.join(["adduser", "-D", "-H", "-u", elements[1], elements[0]]), shell=True)
print("Added user " + elements[0] + " with uid " + elements[1])
if (len(elements) == 4):
subprocess.check_call("addgroup " + elements[0] + " " + elements[3], shell=True)
subprocess.check_call(shlex.join(["addgroup", elements[0], elements[3]]), shell=True)
print("Added user " + elements[0] + " to group " + elements[3])
# set passwd
subprocess.check_call("echo -ne \"" + elements[2] + "\n" + elements[2] + "\n" + "\" | smbpasswd -a -U " + elements[0], shell=True)
subprocess.check_call(shlex.join(["echo", "-ne", "\"" + elements[2] + "\n" + elements[2] + "\n\"", "|", "smbpasswd", "-a", "-U", elements[0]]), shell=True)
print("Set user " + elements[0] + " password to " + elements[2])
main()