Feature #6975

Changing UID/GID when calling spawn/popen

Added by Daniele Orlandi over 1 year ago. Updated about 1 year ago.

[ruby-core:47414]
Status:Closed
Priority:Normal
Assignee:Akira Tanaka
Category:core
Target version:-

Description

Hello,

If I am not wrong it seems that there is no way to properly drop all privileges when spawning a process with spawn/popen.

AFAIK, proper privilege dropping should be done after the fork() and before the exec() and there doesn't seem to be such functionality neither an hook like Python has.

Thanks,
Bye,

Associated revisions

Revision 37124
Added by Nobuyoshi Nakada over 1 year ago

process.c: uid gid exec options

  • process.c (rbexecargaddopt, rbexecargrun_options): add :uid and :gid options. [Feature #6975]

History

#1 Updated by Nobuyoshi Nakada over 1 year ago

  • Description updated (diff)
  • Category set to core
  • Assignee set to akira yamada

Here is a patch
https://github.com/nobu/ruby/compare/uid-gid_exec_options

But I have no ideas how to test this feature.

#2 Updated by Akira Tanaka over 1 year ago

  • Assignee changed from akira yamada to Akira Tanaka

posixspawn has an option to dropping privileges: POSIXSPAWN_RESETIDS

I guess primitive setuid/setgid is too generic for this use case.

#3 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37124.
Daniele, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


process.c: uid gid exec options

  • process.c (rbexecargaddopt, rbexecargrun_options): add :uid and :gid options. [Feature #6975]

#4 Updated by Daniele Orlandi about 1 year ago

Thank you very much!

However it would useful and recommendable if spawn could also initialize additional groups, either directly via setgroups(2) or via initgroups(3)

Do you agree?
Should I create a new feature request?

#5 Updated by Motohiro KOSAKI about 1 year ago

Should I create a new feature request?

Yes, please make another ticket.

Also available in: Atom PDF