[remoting host] Virtual Me2Me sessions should be created from PAM (pam_open_session). |
||
Issue description
The init.d script currently uses 'sudo -i' to create the per-user session.
This creates sessions with an incorrect PAM configuration that are not properly registered as logind sessions.
Instead, we should create the sessions via pam_open_session.
The following information was provided to us:
I looked over /opt/google/chrome-remote-desktop/chrome-remote-desktop, and I think adding a flag like "--drop-privs=${USER}" or "--run-as=${USER}" is the right way to go. That binary would be run as root from the init script *without sudo* and with the flag. Then after the call to daemonize(), it would need to call something like the following run_as(username) function when the flag is set:
import pwd
import os
import PAM
def run_as(username):
user = pwd.getpwnam(username)
pamh = PAM.pam()
pamh.start("chrome-remote-desktop", user.pw_name)
pamh.open_session()
pamh.acct_mgmt(PAM.PAM_SILENT)
pamh.setcred(PAM.PAM_ESTABLISH_CRED | PAM.PAM_SILENT)
pamh.open_session(PAM.PAM_SILENT) # The really important call.
use_env = dict(v.split('=', 1) for v in pamh.getenvlist() if '=' in v)
pid = os.fork():
if pid == 0:
# Child process that will continue to run as "username".
os.setgid(user.pw_gid)
os.initgroups(user.pw_name, user.pw_gid)
os.setuid(user.pw_uid)
for key, value in use_env.iteritems():
os.putenv(key, value)
return # Keep running the rest of the program as the user.
status = os.waitpid(pid, 0)
pamh.setcred(PAM.PAM_DELETE_CRED | PAM.PAM_SILENT)
pamh.close_session()
if os.WIFEXITED(status):
os._exit(os.WEXITSTATUS(status))
else:
...print some warning?...
os._exit(1)
,
Nov 23 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3 commit ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3 Author: rkjnsn <rkjnsn@chromium.org> Date: Wed Nov 23 15:42:54 2016 Add PAM session wrapper Adds a wrapper to launch me2me script in a proper PAM session. BUG= 616962 Review-Url: https://codereview.chromium.org/2323153002 Cr-Commit-Position: refs/heads/master@{#434172} [modify] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/installer/linux/BUILD.gn [modify] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/installer/linux/Makefile [modify] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/installer/linux/debian/chrome-remote-desktop.init [modify] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/installer/linux/debian/chrome-remote-desktop.pam [modify] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/linux/BUILD.gn [modify] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/linux/linux_me2me_host.py [add] https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3/remoting/host/linux/remoting_user_session.cc
,
Nov 23 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/376920771f3df23499f30070f1ce9c2dc7c1a188 commit 376920771f3df23499f30070f1ce9c2dc7c1a188 Author: lukasza <lukasza@chromium.org> Date: Wed Nov 23 19:15:15 2016 Revert of Add PAM session wrapper (patchset #5 id:100001 of https://codereview.chromium.org/2323153002/ ) Reason for revert: This CL seems to have broken the build - see https://uberchromegw.corp.google.com/i/official.desktop.continuous/builders/precise64%20trunk/builds/20292/steps/compile/logs/stdio : [4004/46998] CXX obj/remoting/host/linux/remoting_user_session/remoting_user_session.o FAILED: obj/remoting/host/linux/remoting_user_session/remoting_user_session.o ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/host/linux/remoting_user_session/remoting_user_session.o.d -DV8_DEPRECATION_WARNINGS -DENABLE_NOTIFICATIONS -DENABLE_PDF=1 -DUSE_UDEV -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DENABLE_TASK_MANAGER=1 -DENABLE_THEMES=1 -DUSE_PROPRIETARY_CODECS -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DOFFICIAL_BUILD -DGOOGLE_CHROME_BUILD -DENABLE_MEDIA_ROUTER=1 -DCR_CLANG_REVISION=287685-1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -DCFI_ENFORCEMENT -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -I../.. -Igen -I../../build/linux/debian_wheezy_amd64-sysroot/usr/include/glib-2.0 -I../../build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -fcolor-diagnostics -fdebug-prefix-map=/b/build/slave/precise64_trunk/build/src=. -flto -fwhole-program-vtables -pthread -m64 -march=x86-64 -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-deprecated-register -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -O2 -fno-ident -fdata-sections -ffunction-sections -g2 --sysroot=../../build/linux/debian_wheezy_amd64-sysroot -fsanitize=cfi-vcall -fsanitize-blacklist=../../tools/cfi/blacklist.txt -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -fno-threadsafe-statics -fvisibility-inlines-hidden -std=gnu++11 -fno-rtti -fno-exceptions -c ../../remoting/host/linux/remoting_user_session.cc -o obj/remoting/host/linux/remoting_user_session/remoting_user_session.o ../../remoting/host/linux/remoting_user_session.cc:320:5: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result] fchown(STDOUT_FILENO, pwinfo->pw_uid, pwinfo->pw_gid); ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Original issue's description: > Add PAM session wrapper > > Adds a wrapper to launch me2me script in a proper PAM session. > > BUG= 616962 > > Committed: https://crrev.com/ac6cd2ac8ea912ee4dc0c229f79b04874aee9cc3 > Cr-Commit-Position: refs/heads/master@{#434172} TBR=jamiewalch@chromium.org,lambroslambrou@chromium.org,sergeyu@chromium.org,rkjnsn@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= 616962 Review-Url: https://codereview.chromium.org/2527713002 Cr-Commit-Position: refs/heads/master@{#434218} [modify] https://crrev.com/376920771f3df23499f30070f1ce9c2dc7c1a188/remoting/host/installer/linux/BUILD.gn [modify] https://crrev.com/376920771f3df23499f30070f1ce9c2dc7c1a188/remoting/host/installer/linux/Makefile [modify] https://crrev.com/376920771f3df23499f30070f1ce9c2dc7c1a188/remoting/host/installer/linux/debian/chrome-remote-desktop.init [modify] https://crrev.com/376920771f3df23499f30070f1ce9c2dc7c1a188/remoting/host/installer/linux/debian/chrome-remote-desktop.pam [modify] https://crrev.com/376920771f3df23499f30070f1ce9c2dc7c1a188/remoting/host/linux/BUILD.gn [modify] https://crrev.com/376920771f3df23499f30070f1ce9c2dc7c1a188/remoting/host/linux/linux_me2me_host.py [delete] https://crrev.com/db8a9220deabed531200e613a53d4fe6d87136d5/remoting/host/linux/remoting_user_session.cc
,
Nov 29 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/cbef66778a13c926d0518b269928a288777cbbfc commit cbef66778a13c926d0518b269928a288777cbbfc Author: rkjnsn <rkjnsn@chromium.org> Date: Tue Nov 29 18:50:38 2016 Add PAM session wrapper Adds a wrapper to launch me2me script in a proper PAM session. BUG= 616962 Review-Url: https://codereview.chromium.org/2323153002 Cr-Commit-Position: refs/heads/master@{#435044} [modify] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/installer/linux/BUILD.gn [modify] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/installer/linux/Makefile [modify] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/installer/linux/debian/chrome-remote-desktop.init [modify] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/installer/linux/debian/chrome-remote-desktop.pam [modify] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/linux/BUILD.gn [modify] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/linux/linux_me2me_host.py [add] https://crrev.com/cbef66778a13c926d0518b269928a288777cbbfc/remoting/host/linux/remoting_user_session.cc
,
Dec 15 2016
Fix landed in M57. |
||
►
Sign in to add a comment |
||
Comment 1 by jamiewa...@chromium.org
, Jun 7 2016Status: Assigned (was: Untriaged)