시작된 응용 프로그램이 다른 사용자의 환경 설정 / 이력 / 자원 등을 사용하도록 다른 사용자로 응용 프로그램을 시작하는 방법이 있습니까?
예를 들어 : Alice로 로그인했고 Firefox를 Bob으로 시작하고 싶습니다. 따라서 Firefox는 Alice 대신 Bob의 인터넷 사용 기록을 표시합니다.
나는 시도했다
$ su Bob
$ open -a Firefox
그러나 명백한 효과는 없습니다. 사실 활동 모니터에 따르면 Bob이 아니라 Alice가 Firefox 프로세스를 실행하고 있음이 표시됩니다.
Bob의 로그인 자격 증명이 필요하다는 것을 알고 있지만 문제는 아닙니다.
답변
명령 행 에서 Unix 실행 파일을 찾아 sudo를 사용하여 다음 과 같이 실행해야합니다 .
$ sudo -u Bob /Applications/Firefox.app/Contents/MacOS/Firefox
… 또는 su와 동일 : (그러나 이것은 또한 루트 암호를 설정해야합니다-권장하지 않습니다)
$ su Bob
$ /Applications/Firefox.app/Contents/MacOS/Firefox
(… 또는 위의 한 줄로 🙂
$ su Bob -c /Applications/Firefox.app/Contents/MacOS/Firefox
과거에는 PPC Mac의 가장 쉬운 방법은 Pseudo 를 사용하는 것이었지만 오랫동안 중단되었습니다 . 이것은 의사 아이콘 또는 창에 응용 프로그램 아이콘을 놓기위한 것입니다.
답변
모든 응용 프로그램에서 작동하지 않는 이유 는 /apple//a/102105/1860 을 참조 하십시오su
.
발사 된 bsexec
최신 버전은 launchd
다른 사용자 세션 내에서 응용 프로그램을 시작하는 기능이 있습니다. Apple 엔지니어는 일반적인 사용을 권장하지 않습니다.
적절한 사용자 세션을 대상으로하려면 launchctl 의 bsexec
옵션을 사용하십시오 .
bslist [PID | ..] [-j]
This prints out Mach bootstrap services and their respective states. While the namespace
appears flat, it is in fact hierarchical, thus allowing for certain services to be only avail-
able to a subset of processes. The three states a service can be in are active ("A"), inactive
("I") and on-demand ("D").
If [PID] is specified, print the Mach bootstrap services available to that PID. If [..] is
specified, print the Mach bootstrap services available in the parent of the current bootstrap.
Note that in Mac OS X v10.6, the per-user Mach bootstrap namespace is flat, so you will only
see a different set of services in a per-user bootstrap if you are in an explicitly-created
bootstrap subset.
If [-j] is specified, each service name will be followed by the name of the job which regis-
tered it.
bsexec PID command [args]
This executes the given command in the same Mach bootstrap namespace hierachy as the given
PID.
bstree [-j]
This prints a hierarchical view of the entire Mach bootstrap tree. If [-j] is specified, each
service name will be followed by the name of the job which registered it. Requires root priv-
ileges.
권장되는 방법은 시작된 작업 티켓을 작성하고 Mac을 다시 시작하거나 사용자에게 로그 아웃했다가 다시 로그인하도록 요청하는 것입니다.
답변
한 가지 더 방법 :
# chown someuser command
# chmod u+s command
$ ./command
wysota에게 감사합니다 :
http://www.qtcentre.org/threads/4730-Linux-Bash-Run-a-command-as-another-user
(내 특정 상황에서 작동하는 것을 찾기 위해 많은 시간을 보냈다. 나는 부를 퍼뜨릴 것이라고 생각했다)
답변
당신은 ssh해야합니다. 즉 ssh username@123.456.00
. 당신이 말했듯이, 당신은 사용자의 암호가 필요합니다. 그런 다음 원하는 것을 할 수 있습니다. 시스템 환경 설정> 공유 :에서 원격 로그인을 활성화해야합니다.
그러면 할 수 open -a Firefox
있고 Firefox는 다른 사용자가 아닌 다른 사용자로 열립니다.