Script import users

Salut,

suite a ce post Ynh pour 300 utilisateurs
j’ai bricolé ce script qui permet d’importer des user ynh depuis un csv
si vous avez des retours :slight_smile:
https://esadhar.net/gogs/bachir/ynh-import-users-csv

2 Likes

bon j’ai un souçi

sur certain user, user create n’arrive pas a créer le home folder

    setgid: Invalid argument
    207  WARNING Could not create 'home' folder for user
    Traceback (most recent call last):
      File "/usr/lib/moulinette/yunohost/user.py", line 222, in user_create
        ['su', '-', username, '-c', "''"])
      File "/usr/lib/python2.7/subprocess.py", line 186, in check_call
        raise CalledProcessError(retcode, cmd)
    CalledProcessError: Command '['su', '-', 'pole_tourne', '-c', "''"]' returned non-zero exit status 1

une idée ?

le log complet

yunohost user create pole_tourne -f 'Pole' -l 'Tourne' -m pole_tourne@yuno.dev -p SVnDjx1958-04-04 -q 50M --output-as none --debug
74   DEBUG loading actions map namespace 'yunohost'
85   DEBUG extra parameter classes loaded: ['comment', 'ask', 'password', 'required', 'pattern']
85   DEBUG initializing base actions map parser for cli
86   DEBUG registering new callback action 'yunohost.utils.packages.ynh_packages_version' to ['-v', '--version']
You are now about to define a new user password. The password should be at least 8 characters—though it is good practice to use longer password (i.e. a passphrase) and/or to a variation of characters (uppercase, lowercase, digits and special characters).
133  DEBUG acquiring lock...
148  DEBUG lock has been acquired
151  DEBUG loading python module yunohost.user took 0.003s
151  INFO processing action [106254.1]: yunohost.user.create with args={'username': 'pole_tourne', 'mailbox_quota': '50M', 'firstname': 'Pole', 'lastname': 'Tourne', 'mail': 'pole_tourne@yuno.dev', 'password': 'SVnDjx1958-04-04'}
185  DEBUG initialize authenticator 'as-root' with: uri='ldapi://%2Fvar%2Frun%2Fslapd%2Fldapi', base_dn='dc=yunohost,dc=org', user_rdn='gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth'
    setgid: Invalid argument
    207  WARNING Could not create 'home' folder for user
    Traceback (most recent call last):
      File "/usr/lib/moulinette/yunohost/user.py", line 222, in user_create
        ['su', '-', username, '-c', "''"])
      File "/usr/lib/python2.7/subprocess.py", line 186, in check_call
        raise CalledProcessError(retcode, cmd)
    CalledProcessError: Command '['su', '-', 'pole_tourne', '-c', "''"]' returned non-zero exit status 1
212  DEBUG Group 'pole_tourne' created
214  DEBUG To view the log of the operation 'Create 'pole_tourne' group', use the command 'yunohost log display 20200409-100506-user_group_create-pole_tourne'
223  DEBUG Group 'all_users' updated
240  DEBUG The permission database has been resynchronized
519  DEBUG SSOwat configuration generated
525  DEBUG To view the log of the operation 'Update 'all_users' group', use the command 'yunohost log display 20200409-100506-user_group_update-all_users'
527  SUCCESS User created
527  DEBUG No default hook for action 'post_user_create' in /usr/share/yunohost/hooks/
527  DEBUG No custom hook for action 'post_user_create' in /etc/yunohost/hooks.d/
528  DEBUG To view the log of the operation 'Add 'pole_tourne' user', use the command 'yunohost log display 20200409-100506-user_create-pole_tourne'
529  DEBUG action [106254.1] executed in 0.378s
529  DEBUG lock has been released

J’ai trouvé la source du bug
ça ne vient ni de mon script ni de ynh mais de mon container lxc dont l’idmap était limité a 65536 là ou ynh tape jusqu’a 99999


https://wiki.archlinux.org/index.php/Linux_Containers#Enable_support_to_run_unprivileged_containers_(optional)
https://stgraber.org/2017/06/15/custom-user-mappings-in-lxd-containers/