分别是提权和取消提权后的结果,并请告知发行版本和桌面环境,谢谢了,拜托
pkexec echo x; echo $?;
1
churchmice Jun 29, 2023
RETURN VALUE
Upon successful completion, the return value is the return value of PROGRAM. If the calling process is not authorized or an authorization could not be obtained through authentication or an error occured, pkexec exits with a return value of 127. If the authorization could not be obtained because the user dismissed the authentication dialog, pkexec exits with a return value of 126. |
2
Donahue Jun 29, 2023 ubuntu22.04
需要输入密码运行这个命令,运行后得到输出 x 0 |
3
coolfan Jun 29, 2023 Ubuntu 22.04.2 LTS on Windows 10 x86_64
****@LAPTOP-Fan:~$ sudo pkexec echo x; echo $?; [sudo] password for ****: x 0 |
4
GeruzoniAnsasu Jun 29, 2023 我遇到了跟这个问题完全一致的现象:
https://askubuntu.com/questions/799669/etc-sudoers-file-corrupted-and-i-cant-run-pkexec-visudo-over-ssh 在单会话 SSH 中 auth 失败。 但 systemctl 这样的提权命令又是能成功通过验证的 sudo pkexec 正常 |
5
WillNiubiRR Jun 29, 2023 Error executing command as another user: Request dismissed
126 Ubuntu 23.04 |
6
bjzhush Jun 29, 2023 ➜ ~ uname -a
Linux vultr 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ➜ ~ cat /etc/issue Ubuntu 22.04.2 LTS \n \l ➜ ~ pkexec echo x; echo $?; x 0 ➜ ~ |
7
xiaobai1213 Jun 29, 2023 |
8
oIMOo Jun 29, 2023 admin 账户 sudo 前缀
x 0 Linux itis-bli-20476 5.19.0-43-generic #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon May 22 13:39:36 UTC 2 x86_64 x86_64 x86_64 GNU/Linux |
9
vrqq Jun 29, 2023 ```bash
$ pkexec echo x; echo $?; ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ==== Authentication is needed to run `/usr/bin/echo' as the super user Authenticating as: vrqq Password: polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie ==== AUTHENTICATION FAILED ==== Error executing command as another user: Not authorized This incident has been reported. 127 $ sudo pkexec echo x; echo $?; x 0 $ gnome-shell --version GNOME Shell 40.10 ``` Red Hat Enterprise Linux release 9.2 (Plow) Linux rhedt 5.14.0-284.18.1.el9_2.x86_64 |
10
yanqiyu Jun 30, 2023 ❯ pkexec echo x; echo $?;
Error executing command as another user: Request dismissed 126 ❯ pkexec echo x; echo $?; x 0 ❯ cat /etc/redhat-release Fedora release 38 (Thirty Eight) |
11
basncy Jun 30, 2023
支持楼主开发桌面 app.
可以 ps -ef 检查有没有 polkit 进程来接收请求, 没有就返回 127, 有就是 0. 不同桌面环境进程名不一样, xfce 和 i3 桌面环境是 /usr/lib/xfce-polkit/xfce-polkit https://wiki.archlinux.org/title/Polkit |
12
0superx0 Jun 30, 2023
lin@x:~$ pkexec echo x; echo $?;
x 0 lin@x:~$ neofetch ##### lin@x ####### ----- ##O#O## OS:ubuntu 18.04 x86_64 ####### Host: 2325GB6 ThinkPad X230 ########### Kernel: 6.1.0-20230601 ############# Uptime: 1 day, 5 hours, 16 mins ############### Packages: 2175 ################ Shell: bash 4.4.20 ################# Resolution: 1920x1080 ##################### DE: Unity:Unity7:ubuntu ##################### WM: Compiz ################# WM Theme: Adwaita Theme: Ambiance [GTK2/3] Icons: Ubuntu-mono-dark [GTK2/3] Terminal: gnome-terminal CPU: Intel i7-3615QE (8) @ 3.300GHz GPU: Intel HD Graphics 4000 Memory: 2472MiB / 15576MiB |
13
xshell Jun 30, 2023
root@debian12:~# pkexec echo x; echo $?;
x 0 |
14
sunnysab Jun 30, 2023
[sunnysab@archlinux ~]$ pkexec echo x; echo $?;
x 0 执行前弹出了密码输入框。 |
15
wozhidaole Jun 30, 2023
[root@VM-4-10-centos ~]# pkexec echo x; echo $?;
x 0 [root@VM-4-10-centos ~]# uname -a Linux VM-4-10-centos 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux [root@VM-4-10-centos ~]# |
16
luozic Jun 30, 2023
ubuntu23.04
Ubuntu@ubuntu:~$ pkexec echo x; echo $?; x 0 |
17
userff Jun 30, 2023
Deepin 20.9
```bash # f @ f-PC in ~ [9:29:17] $ pkexec echo x; echo $?; x 0 ``` |
18
ecee Jun 30, 2023
archlinux, 桌面是 vnc 启动的 xfce ,需要输入 root 密码
[test@legion ~]$ pkexec echo x; echo$?; x 0 |
19
DOOMS Jun 30, 2023
ubun-virtual-machine ~ » pkexec echo x; echo $?;
x 0 但是需要输入密码 环境: yyyyy- -yyyyyy+ OS: Ubuntu 18.04 bionic ://+//////-yyyyyyo Kernel: x86_64 Linux 5.4.0-150-generic |
20
sxzzsf Jun 30, 2023
bash: pkexec: command not found
127 |
21
ljn917 Jun 30, 2023 via Android
```
$ pkexec echo x; echo $?; x 0 ``` Fedora 37, KDE, 会提示输入 root 密码 |
22
lesteryou Jun 30, 2023
Deepin 20.9
Linux Ori-DP 5.17.3-amd64-desktop #1 SMP PREEMPT Fri Apr 29 15:22:29 CST 2022 x86_64 GNU/Linux ``` ~ ⌚ 9:57:42 $ pkexec echo x; echo $? x 0 ``` 回车后,弹出密码验证框 |
23
dbskcnc Jun 30, 2023
manjaro kde
pkexec echo x; echo $? x 0 pkexec echo x; echo $? Error executing command as another user: Not authorized This incident has been reported. 127 |
24
zsj1029 Jun 30, 2023
~ sudo pkexec echo x; echo $?;
x 0 ~ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux trixie/sid Release: n/a Codename: trixie Debian 12 |
25
kgcHQbTYyvcz2w3j Jun 30, 2023
Arch Linux 6.3.8-arch1-1 直接 x11 套 awesome wm , 加不加 sudo 有两种结果
$ pkexec echo x; echo $?; x 0 $ sudo pkexec echo x; echo $?; ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ==== Authentication is needed to run `/usr/bin/echo' as the super user Authenticating as: Max (max) Password: polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie ==== AUTHENTICATION FAILED ==== Error executing command as another user: Not authorized This incident has been reported. 127 |
26
kokutou Jun 30, 2023
msys2
➜ ~ pkexec echo x; echo $?; zsh: command not found: pkexec 127 ➜ ~ |
27
leehomyhh Jun 30, 2023
[root@dev3430 ~]# pkexec echo x; echo $?;
x 0 |
28
Mikewangyankkk Jun 30, 2023
[root@ypzflqgbrczsm2nr ~]# neofetch
##### [email protected] ####### ------------------------------- ##O#O## OS: Anolis OS 8.8 x86_64 ####### Host: OpenStack Compute 17.0.3-1.el7 ########### Kernel: 5.10.134-14.1.an8.x86_64 ############# Uptime: 22 days, 21 hours, 1 min ############### Packages: 823 (rpm) ################ Shell: bash 4.4.20 ################# Resolution: 1024x768 ##################### Terminal: /dev/pts/0 ##################### CPU: Intel Xeon (Skylake, IBRS) (2) @ 2.299GHz ################# GPU: 00:02.0 Cirrus Logic GD 5446 Memory: 846MiB / 3725MiB [root@ypzflqgbrczsm2nr ~]# pkexec echo x; echo $?; x 0 |
29
xiaofami Jun 30, 2023
Manjaro ARM:
[marly@manjaro ~]$ sudo inxi -F System: Host: manjaro Kernel: 6.3.0-1-MANJARO-ARM-ODROID arch: aarch64 bits: 64 Console: pty pts/1 Distro: Manjaro ARM Machine: Type: ARM System: Amlogic Meson GXBB P201 Development Board details: N/A CPU: Info: quad core model: N/A variant: cortex-a53 bits: 64 type: MCP Speed (MHz): avg: 2016 min/max: 100/2016 cores: 1: 2016 2: 2016 3: 2016 4: 2016 Graphics: Device-1: meson-gxbb-dw-hdmi driver: meson_dw_hdmi v: N/A Device-2: meson-gxbb-vpu driver: meson_drm v: N/A Device-3: meson-gxbb-mali driver: lima v: kernel Display: server: Xwayland v: 23.1.1 driver: N/A tty: 179x49 API: EGL/GBM Message: No known Wayland EGL/GBM data sources. Audio: Device-1: meson-gxbb-dw-hdmi driver: meson_dw_hdmi API: ALSA v: k6.3.0-1-MANJARO-ARM-ODROID status: kernel-api Network: Device-1: meson-gxbb-dwmac driver: meson8b_dwmac IF: eth0 state: up speed: 100 Mbps duplex: full mac: 2e:a9:49:75:91:71 Device-2: pwm-clock driver: pwm_clock IF-ID-1: ip6tnl0 state: down mac: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 Drives: Local Storage: total: 123.02 GiB used: 14.85 GiB (12.1%) ID-1: /dev/mmcblk0 model: ED2S5 size: 119.38 GiB ID-2: /dev/mmcblk1 model: 4FPD3R size: 3.64 GiB Partition: ID-1: / size: 116.99 GiB used: 14.79 GiB (12.6%) fs: ext4 dev: /dev/mmcblk0p2 ID-2: /boot size: 457.5 MiB used: 53.8 MiB (11.8%) fs: vfat dev: /dev/mmcblk0p1 Swap: Alert: No swap data was found. Sensors: Src: lm-sensors+/sys Message: No sensor data found using /sys/class/hwmon or lm-sensors. Info: Processes: 158 Uptime: 18d 8h 21m Memory: available: 922.9 MiB used: 474.8 MiB (51.4%) Init: systemd Shell: Bash inxi: 3.3.27 [marly@manjaro ~]$ pkexec echo x; echo $?; ==== AUTHENTICATING FOR org.freedesktop.policykit.exec ==== Authentication is needed to run `/usr/bin/echo' as the super user Authenticating as: marly Password: polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie ==== AUTHENTICATION FAILED ==== Error executing command as another user: Not authorized This incident has been reported. 127 [marly@manjaro ~]$ sudo pkexec echo x; echo $?; x 0 |