I'm on Mac OS X 10.5.6.
I did a few searches, but didn't find a match. I did find old posts
about how Process.uid= can't handle negative UID's which is another
issue I'm fighting, but nothing about this issue.
If that were the case, would it maybe be possible to switch users
using Apple's alternate API?
Unfortunately, this issue is a big snag that's preventing us from
shipping an application, so I've got to find some workaround. I've
considered trying to exec() my program adding su/sudo to switch the
user as a possible option. Would that work? I need to switch both
the user and group.
James Edward Gray II
Does something like this not work for you?
def _change_privilege(user, group=user)
uid, gid = Process.euid, Process.egid
begin
target_uid = Etc.getpwnam(user).uid
rescue ArgumentError => e
return false
end
begin
target_gid = Etc.getgrnam(group).gid
rescue ArgumentError => e
return false
end
if (uid != target_uid) || (gid != target_gid)
# Change process ownership
Process.initgroups(user, target_gid)
Process::GID.change_privilege(target_gid)
Process::UID.change_privilege(target_uid)
end
true
rescue Errno::EPERM => e
false
end
Cheers-
Ezra Zygmuntowicz
(e-mail address removed)