로그인할 때 pam_exec 환경에 대화 상자를 표시하시겠습니까?

로그인할 때 pam_exec 환경에 대화 상자를 표시하시겠습니까?

나는 그것을 pam_exec몇 가지 루트 작업을 수행하는 데 사용합니다. 시간이 좀 걸리므로 사용자에게 잠시 기다리라고 말하고 싶습니다.

나는 다음을 수행해야 하기 때문에 나중이 아니라 바로 그 자리에서 작업을 수행합니다.

  • 루트 권한
  • 서버에서 마스터 파일을 재동기화하기 전아무것데스크탑에 로드

내 문제는 아무것도 표시하는 창을 표시할 수 없다는 것입니다. pam_exec이것이 $DISPLAY문제인지 아니면 사용자 문제인지 테스트하기 위해 이 스크립트를 로드합니다 .

#!/bin/bash

case "$PAM_TYPE" in

    'open_session')

    echo Plain exec &> /tmp/pamexec_output
    yad &>> /tmp/pamexec_output
    echo Set display &>> /tmp/pamexec_output
    DISPLAY=:0 yad &>> /tmp/pamexec_output
    echo Set user lightdm &>> /tmp/pamexec_output
        sudo -u lightdm yad &>> /tmp/pamexec_output
    echo Set user $PAM_USER &>> /tmp/pamexec_output
        sudo -u $PAM_USER yad &>> /tmp/pamexec_output
    echo Set user lightdm and display &>> /tmp/pamexec_output
    DISPLAY=:0 sudo -u lightdm yad &>> /tmp/pamexec_output
    echo Set user $PAM_USER and display &>> /tmp/pamexec_output
    DISPLAY=:0 sudo -u $PAM_USER yad &>> /tmp/pamexec_output
    echo PS AUX &>> /tmp/pamexec_output
    ps aux &>> /tmp/pamexec_output

    ;;

esac

창과 출력을 표시하지 않으면 답변을 얻을 수 없습니다.

Plain exec
No protocol specified
No protocol specified

(yad:25314): Gtk-WARNING **: cannot open display: :0
Set display
No protocol specified
No protocol specified

(yad:25317): Gtk-WARNING **: cannot open display: :0
Set user lightdm
No protocol specified
No protocol specified

(yad:25321): Gtk-WARNING **: cannot open display: :0
Set user jorge.suarez
No protocol specified
No protocol specified

(yad:25325): Gtk-WARNING **: cannot open display: :0
Set user lightdm and display
No protocol specified
No protocol specified

(yad:25328): Gtk-WARNING **: cannot open display: :0
Set user jorge.suarez and display
No protocol specified
No protocol specified

(yad:25331): Gtk-WARNING **: cannot open display: :0

보너스로 다음은 의 최종 출력입니다 ps aux. 아마도 이것이 도움이 될 것입니다.

PS AUX
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2  26684  2488 ?        Ss   Jan24   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Jan24   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Jan24   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S    Jan24   0:00 [kworker/u:0]
root         6  0.0  0.0      0     0 ?        S    Jan24   0:00 [migration/0]
root         7  0.0  0.0      0     0 ?        S    Jan24   0:00 [watchdog/0]
root         8  0.0  0.0      0     0 ?        S<   Jan24   0:00 [cpuset]
root         9  0.0  0.0      0     0 ?        S<   Jan24   0:00 [khelper]
root        10  0.0  0.0      0     0 ?        S    Jan24   0:00 [kdevtmpfs]
root        11  0.0  0.0      0     0 ?        S<   Jan24   0:00 [netns]
root        12  0.0  0.0      0     0 ?        S    Jan24   0:00 [sync_supers]
root        13  0.0  0.0      0     0 ?        S    Jan24   0:00 [bdi-default]
root        14  0.0  0.0      0     0 ?        S<   Jan24   0:00 [kintegrityd]
root        15  0.0  0.0      0     0 ?        S<   Jan24   0:00 [kblockd]
root        16  0.0  0.0      0     0 ?        S<   Jan24   0:00 [ata_sff]
root        17  0.0  0.0      0     0 ?        S    Jan24   0:00 [khubd]
root        18  0.0  0.0      0     0 ?        S<   Jan24   0:00 [md]
root        21  0.0  0.0      0     0 ?        S    Jan24   0:00 [khungtaskd]
root        22  0.0  0.0      0     0 ?        S    Jan24   0:00 [kswapd0]
root        23  0.0  0.0      0     0 ?        SN   Jan24   0:00 [ksmd]
root        24  0.0  0.0      0     0 ?        SN   Jan24   0:00 [khugepaged]
root        25  0.0  0.0      0     0 ?        S    Jan24   0:00 [fsnotify_mark]
root        26  0.0  0.0      0     0 ?        S    Jan24   0:00 [ecryptfs-kthrea]
root        27  0.0  0.0      0     0 ?        S<   Jan24   0:00 [crypto]
root        35  0.0  0.0      0     0 ?        S<   Jan24   0:00 [kthrotld]
root        36  0.0  0.0      0     0 ?        S    Jan24   0:00 [scsi_eh_0]
root        37  0.0  0.0      0     0 ?        S    Jan24   0:08 [scsi_eh_1]
root        38  0.0  0.0      0     0 ?        S    Jan24   0:00 [kworker/u:2]
root        59  0.0  0.0      0     0 ?        S<   Jan24   0:00 [devfreq_wq]
root       206  0.0  0.0      0     0 ?        S    Jan24   0:02 [jbd2/vda5-8]
root       207  0.0  0.0      0     0 ?        S<   Jan24   0:00 [ext4-dio-unwrit]
root       227  0.0  0.1  30844  1256 ?        S    Jan24   0:00 mountall --daemon
root       302  0.0  0.0  17224   640 ?        S    Jan24   0:00 upstart-udev-bridge --daemon
root       305  0.0  0.2  24524  2172 ?        Ss   Jan24   0:00 /sbin/udevd --daemon
root       431  0.0  0.0      0     0 ?        S<   Jan24   0:00 [kpsmoused]
root       504  0.0  0.1  19192  1032 ?        Ss   Jan24   0:00 rpcbind -w
root       513  0.0  0.0      0     0 ?        S    Jan24   0:00 [jbd2/vda6-8]
root       514  0.0  0.0      0     0 ?        S<   Jan24   0:00 [ext4-dio-unwrit]
root       532  0.0  0.0  15180   404 ?        S    Jan24   0:00 upstart-socket-bridge --daemon
root       570  0.0  0.0      0     0 ?        S    Jan24   0:00 [jbd2/vda7-8]
root       573  0.0  0.0      0     0 ?        S<   Jan24   0:00 [ext4-dio-unwrit]
root       655  0.0  0.0      0     0 ?        S<   Jan24   0:00 [rpciod]
root       658  0.0  0.0      0     0 ?        S<   Jan24   0:00 [nfsiod]
root       669  0.0  0.2  49948  2716 ?        Ss   Jan24   0:00 /usr/sbin/sshd -D
102        679  0.0  0.2  27184  2536 ?        Ss   Jan24   0:17 dbus-daemon --system --fork --activation=upstart
root       709  0.0  0.3  79036  3096 ?        Ss   Jan24   0:00 /usr/sbin/modem-manager
root       717  0.0  0.1  21180  1692 ?        Ss   Jan24   0:00 /usr/sbin/bluetoothd
syslog     733  0.0  0.1 249464  1404 ?        Sl   Jan24   0:02 rsyslogd -c5
root       738  0.0  0.5 229848  5260 ?        Ssl  Jan24   0:05 NetworkManager
root       746  0.0  0.0      0     0 ?        S<   Jan24   0:00 [krfcommd]
root       756  0.0  0.6 188336  5844 ?        Sl   Jan24   0:23 /usr/lib/policykit-1/polkitd --no-debug
statd      773  0.0  0.1  21496  1312 ?        Ss   Jan24   0:00 rpc.statd -L
avahi      780  0.0  0.1  34396  1716 ?        S    Jan24   0:00 avahi-daemon: registering [ctdeskxyy.local]
avahi      781  0.0  0.0  34268   472 ?        S    Jan24   0:00 avahi-daemon: chroot helper
root       787  0.0  0.1   7256  1508 ?        S    Jan24   0:00 /sbin/dhclient -d -4 -sf /usr/lib/NetworkManager/nm-dhcp-client.action -pf /var/run/sendsigs.omit.d/network-manager.dhclient-eth0.pid -lf /var/lib/dhcp/dhclient-05584152-142d-425d-b5b9-1e63697e0637-eth0.lease -cf /var/run/nm-dhclient-eth0.conf eth0
colord     808  0.0  1.2 491876 11588 ?        Sl   Jan24   0:01 /usr/lib/x86_64-linux-gnu/colord/colord
root       938  0.0  0.0  19980   932 tty4     Ss+  Jan24   0:00 /sbin/getty -8 38400 tty4
root       948  0.0  0.0  19980   940 tty5     Ss+  Jan24   0:00 /sbin/getty -8 38400 tty5
root       961  0.0  0.2  69768  1904 tty3     Ss   Jan24   0:00 /bin/login --             
root       964  0.0  0.0  19980   936 tty6     Ss+  Jan24   0:00 /sbin/getty -8 38400 tty6
root       983  0.0  0.0   4452   812 ?        Ss   Jan24   0:00 acpid -c /etc/acpi/events -s /var/run/acpid.socket
root       984  0.0  0.1  19104  1024 ?        Ss   Jan24   0:00 cron
daemon     985  0.0  0.0  16900   372 ?        Ss   Jan24   0:00 atd
root       991  0.0  0.3 262560  3396 ?        Ssl  Jan24   0:01 lightdm
whoopsie   993  0.0  0.5 202176  5024 ?        Ssl  Jan24   0:01 whoopsie
nobody    1001  0.0  0.1  33016  1252 ?        S    Jan24   0:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/sendsigs.omit.d/network-manager.dnsmasq.pid --listen-address=127.0.0.1 --conf-file=/var/run/nm-dns-dnsmasq.conf --cache-size=0 --proxy-dnssec
root      1023  0.0  0.1 701376  1192 ?        Ssl  Jan24   0:00 /usr/sbin/nscd
nslcd     1111  0.0  0.2 443796  1916 ?        Ssl  Jan24   0:00 /usr/sbin/nslcd
root      1254  0.0  0.4 586496  4152 ?        Sl   Jan24   0:08 /usr/sbin/console-kit-daemon --no-daemon
root      1362  0.0  0.0      0     0 ?        S    Jan24   0:01 [flush-253:0]
root      1534  0.0  0.2  76052  2032 tty1     Ss   Jan24   0:00 /bin/login --              
root      1536  0.0  0.4 219940  4272 ?        Sl   Jan24   0:01 /usr/lib/upower/upowerd
rtkit     1567  0.0  0.1 160644  1136 ?        SNl  Jan24   0:00 /usr/lib/rtkit/rtkit-daemon
1000      1782  0.0  0.4  19556  4676 tty1     S    Jan24   0:00 -bash
root      1930  0.0  0.2  66712  1904 tty1     S    Jan24   0:00 sudo su
root      1931  0.0  0.1  66472  1816 tty1     S    Jan24   0:00 su
root      1941  0.0  0.2  17260  2324 tty1     S+   Jan24   0:01 bash
root      1965  0.0  0.0      0     0 ?        S    Jan24   0:00 [lockd]
root      2505  0.0  0.3 193524  3628 ?        Sl   Jan24   0:01 /usr/lib/udisks/udisks-daemon
root      2506  0.0  0.0  45512   804 ?        S    Jan24   0:00 udisks-daemon: not polling any devices
root      5436  0.0  0.4  98476  4256 ?        Ss   08:01   0:00 /usr/sbin/cupsd -F
root     11778  0.0  0.0      0     0 ?        S<   08:01   0:00 [xfs_mru_cache]
root     11779  0.0  0.0      0     0 ?        S<   08:01   0:00 [xfslogd]
root     11780  0.0  0.0      0     0 ?        S<   08:01   0:00 [xfsdatad]
root     11781  0.0  0.0      0     0 ?        S<   08:01   0:00 [xfsconvertd]
root     11784  0.0  0.0      0     0 ?        S    08:01   0:00 [jfsIO]
root     11785  0.0  0.0      0     0 ?        S    08:01   0:00 [jfsCommit]
root     11786  0.0  0.0      0     0 ?        S    08:01   0:00 [jfsSync]
root     13718  0.0  0.0      0     0 ?        Z    Jan24   0:00 [lightdm] <defunct>
root     14197  0.0  0.1  24520  1640 ?        S    08:03   0:00 /sbin/udevd --daemon
root     14198  0.0  0.0      0     0 ?        S<   08:03   0:00 [iprt]
root     16911  0.0  0.2  69768  1904 tty2     Ss   Jan24   0:00 /bin/login --             
root     18750  0.0  0.3 124052  3712 ?        Sl   09:12   0:00 /usr/lib/accountsservice/accounts-daemon
root     21715  0.0  0.0      0     0 ?        Z    09:20   0:00 [lightdm] <defunct>
4004     23593  0.0  0.3 207504  3592 ?        Sl   09:35   0:00 /usr/lib/deja-dup/deja-dup/deja-dup-monitor
root     24087  0.0  0.0      0     0 ?        S    09:42   0:00 [kworker/0:1]
root     24355  0.0  0.0      0     0 ?        S    09:47   0:00 [kworker/0:2]
root     24581  0.1  2.6 122056 24912 ?        SN   09:48   0:00 /usr/bin/python /usr/sbin/aptd
root     25026  0.1  0.0      0     0 ?        S    09:52   0:00 [kworker/0:0]
root     25134  1.8  2.6 148396 25280 tty7     Ss+  09:53   0:00 /usr/bin/X :0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
root     25226  0.0  0.3 155028  3136 ?        Sl   09:53   0:00 lightdm --session-child 12 385
lightdm  25258  0.1  0.5 344020  5200 ?        S<l  09:53   0:00 /usr/bin/pulseaudio --start --log-target=syslog
lightdm  25263  0.0  0.3  95984  3240 ?        S    09:53   0:00 /usr/lib/pulseaudio/pulse/gconf-helper
root     25313  0.0  0.1  16516  1376 ?        Ss   09:54   0:00 /bin/bash /usr/local/lib/puppet-files/gestion-sesiones.sh log=/tmp/cosaaaa
root     25334  0.0  0.1  14144  1020 ?        R    09:54   0:00 ps aux
4004     26833  0.0  0.5 362740  5676 ?        S<l  Jan24   0:01 /usr/bin/pulseaudio --start --log-target=syslog
4004     26836  0.0  0.3  95968  3256 ?        S    Jan24   0:00 /usr/lib/pulseaudio/pulse/gconf-helper
root     28396  0.0  0.0      0     0 ?        Z    Jan24   0:00 [lightdm] <defunct>
4004     29073  0.0  0.4  19536  4660 tty2     S+   Jan24   0:00 -bash
4004     29256  0.0  0.4  19488  4468 tty3     S+   Jan24   0:00 -bash

또 다른 흥미로운 발견. 이 스크립트는 다음과 같습니다.

#!/bin/bash

case "$PAM_TYPE" in

    'open_session')

    (
         sleep 5
         yad &> /tmp/pam_output
    ) &

    ;;

esac

작동하지만 데스크탑이 로드된 후에 창이 표시됩니다. 그래서 이것은 도움이 되지 않습니다.

로그아웃해도 작동하는데 문제 없습니다.

이 문제를 해결하는 방법에 대한 아이디어가 있습니까?

답변1

pam_exec를 파일에 작성하고(/tmp/pam_output과 마찬가지로) 사용자가 /tmp/pam_output을 모니터링하고 새 출력을 볼 때 메시지를 팝업하는 별도의 데몬으로 로그인하기 전에 lightdm에 의해 실행되도록 할 수 있습니다. lightdm이 실행하는 백그라운드 프로세스에는 X 환경과 X11 쿠키 세트가 있으며 루트가 아닌 lightdm 사용자의 컨텍스트에서 실행되므로 어쨌든 더 안전합니다. 바라보다이 문서환영 프로그램이 시작되면 스크립트를 시작합니다.

관련 정보