Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UID/GIDを指定できるようにしてほしい #37

Open
LWisteria opened this issue May 20, 2024 · 6 comments · May be fixed by #38
Open

UID/GIDを指定できるようにしてほしい #37

LWisteria opened this issue May 20, 2024 · 6 comments · May be fixed by #38

Comments

@LWisteria
Copy link
Member

複数ノードを使う場合に合わせたいことがあるので、例えば

  • create NodeA 1006 1006とかするとUID=1006, GID=1006で作られる
  • すでにあるUID/GIDと衝突する場合は、とりあえずエラーで返す

あたりだけでもあるとありがたいです。

@toru-fukaya
Copy link
Collaborator

toru-fukaya commented May 20, 2024

TODO: useradd -u uid -g gid で期待通りになるか確かめる

@toru-fukaya
Copy link
Collaborator

toru-fukaya commented May 20, 2024

こうなるので先にグループを作る必要がありそう?

$ sudo useradd -m -s /bin/bash -p "" -u 2000 -g 2000 test
useradd: group '2000' does not exist

@toru-fukaya
Copy link
Collaborator

toru-fukaya commented May 20, 2024

GIDがUIDと同じで良ければ出来そう

$ sudo useradd -m -s /bin/bash -p "" -u 2000 test
$ sudo su -l test
$ id
uid=2000(test) gid=2000(test) groups=2000(test)

@toru-fukaya
Copy link
Collaborator

既にgroupがあれば通る

$ sudo useradd -m -s /bin/bash -p "" -u 2001 -g 2000 test2
$ sudo su -l test2
$ id
uid=2001(test2) gid=2000(test) groups=2000(test)

@toru-fukaya
Copy link
Collaborator

$ sudo groupadd -g 2002 test3
$ sudo useradd -m -s /bin/bash -p "" -u 2002 -g 2002 test3
$ sudo su -l test3
$ id
uid=2002(test3) gid=2002(test3) groups=2002(test3)

@toru-fukaya
Copy link
Collaborator

toru-fukaya commented May 20, 2024

if ! grep "^[^:]*:x:gid:$" /etc/group >/dev/null; then
    groupadd -g gid username
fi
useradd -m -s /bin/bash -p "" -u uid -g gid username

@toru-fukaya toru-fukaya linked a pull request Jun 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants