Skip to content

Feature Request: Add user management mutations to GraphQL API #1987

@djlongy

Description

@djlongy

Summary

There is currently no programmatic way to create Unraid users that the web GUI recognises without a reboot. The GraphQL API at /graphql exposes read-only user queries (me, UserAccount) but has no mutations for creating, updating, or deleting users.

This is a feature request to add user management mutations (createUser, updateUser, deleteUser) to the GraphQL API.

Use Case

Automating user provisioning for homelab RBAC — creating users with specified UIDs/GIDs, group memberships, and share permissions at boot time without manual GUI interaction. This is essential for infrastructure-as-code workflows where user/permission state should be declarative and reproducible.

What Was Tested (Unraid 7.2.2)

Every available method for programmatic user creation was exhaustively tested. None produce a GUI-visible user without a reboot:

Method User Created? Visible in GUI? Notes
GUI (Add User) Yes Yes Works perfectly — the baseline
useradd + config file writes Yes After reboot only System/SMB access works immediately, but GUI doesn't see the user until reboot
emcmd cmdUserEdit=Add No (hangs) N/A Blocks indefinitely; no useradd entry in syslog. Interestingly, cmdUserEdit=Delete does work
Direct socket write to emhttpd No N/A HTTP 500 or timeout
curl via nginx with session cookie No (502) N/A nginx times out waiting for emhttpd
Append to users.ini N/A No File is present but GUI ignores it until reboot
GraphQL API No (no mutation exists) N/A addUser, createUser, setUser, updateUser all return "Cannot query field on type Mutation"

What the GUI Does Internally (syslog observation)

When creating a user through the web GUI, emhttpd executes:

emhttpd: shcmd (137): useradd -g users -d / -s /bin/false -c '' 'testgui'
useradd: new user: name=testgui, UID=2003, GID=100, home=/, shell=/bin/false
chpasswd: password changed for testgui
emhttpd: Restarting services...
emhttpd: shcmd (145): /etc/rc.d/rc.samba reload
emhttpd: shcmd (148): exportfs -ra
emhttpd: shcmd (150): /etc/rc.d/rc.avahidaemon reload
emhttpd: shcmd (155): cp /etc/passwd /etc/shadow /var/lib/samba/private/smbpasswd /boot/config

The key insight: emhttpd manages user creation internally and copies config files from /etc/ to /boot/config/. The GUI user list is populated from these files at boot, and there's no mechanism to trigger a refresh at runtime from outside emhttpd.

What We're Requesting

  1. GraphQL mutations for user management: createUser, updateUser, deleteUser — with parameters for username, password, UID (optional), groups, and share permissions
  2. Real-time GUI refresh: Users created via the API should appear in the GUI immediately without requiring a reboot
  3. Service reload: The API should handle reloading samba/NFS/avahi after user changes (as the GUI already does internally)

Questions

  1. Why does emcmd cmdUserEdit=Delete work from CLI but cmdUserEdit=Add hangs indefinitely?
  2. Is there a signal or command to force emhttpd to re-read its user list at runtime?
  3. Are there plans to expose user management through the API?

Forum Discussion

This was originally posted on the Unraid forums with full technical details:
https://forums.unraid.net/topic/190436-creating-users-from-command-line/

Environment

  • Unraid 7.2.2
  • Slackware 15.0+, x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions