# Starting specific program with sudo

**URL:** <https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229>\
**Category:** Ask Fedora\
**Created:** [October 20, 2024, 7:34pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229 "2024-10-20T19:34:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 20, 2024, 7:34pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/1 "2024-10-20T19:34:40Z")

</div>

Hi, I need the proxy manager Nekoray to always start in sudo mode, so that I don’t need to enter the sudo password multiple times when using the program.

(I know this can be done in the terminal, but it is inconvenient, plus I would need to keep the respective terminal window open.)

(1) Is this possible in Fedora 40 Gnome?

(2) If it isn’t, how do I at least run Nekoray with sudo privileges at system start-up?

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 20, 2024, 8:28pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/3 "2024-10-20T20:28:56Z")

</div>

Thank you.

This will create a systemd Nekoray service starting at Fedora startup, right?

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 20, 2024, 8:48pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/4 "2024-10-20T20:48:17Z")

</div>

I have executed the command, it was successful, but after a restart I ran Nekoray and it still requests a password.

(Just so I don’t sound too picky, I’ll explain – the program asks for the password three times, to turn on various network modes, which is quite annoying.)

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 20, 2024, 8:50pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/6 "2024-10-20T20:50:21Z")

</div>

```plaintext
$ journalctl --no-pager -b -u nekoray.service

Oct 20 23:45:38 x270 systemd[1]: Started nekoray.service - Nekoray service.
Oct 20 23:45:38 x270 systemd[1]: nekoray.service: Main process exited, code=exited, status=203/EXEC
Oct 20 23:45:38 x270 systemd[1]: nekoray.service: Failed with result 'exit-code'.

```

```plaintext
$ systemctl status nekoray.service
× nekoray.service - Nekoray service
     Loaded: loaded (/etc/systemd/system/nekoray.service; enabled; preset: disa>
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: failed (Result: exit-code) since Sun 2024-10-20 23:45:38 MSK; 8min>
   Duration: 13ms
    Process: 1441 ExecStart=/path/to/nekoray... (code=exited, status=203/EXEC)
   Main PID: 1441 (code=exited, status=203/EXEC)
        CPU: 1ms

Oct 20 23:45:38 x270 systemd[1]: Started nekoray.service - Nekoray service.
Oct 20 23:45:38 x270 systemd[1]: nekoray.service: Main process exited, code=exi>
Oct 20 23:45:38 x270 systemd[1]: nekoray.service: Failed with result 'exit-code>
lines 1-13/13 (END)

```

```plaintext
# /etc/systemd/system/nekoray.service
[Unit]
Description=Nekoray service
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/path/to/nekoray...
[Install]
WantedBy=multi-user.target

# /usr/lib/systemd/system/service.d/10-timeout-abort.conf
# This file is part of the systemd package.
# See https://fedoraproject.org/wiki/Changes/Shorter_Shutdown_Timer.
#
# To facilitate debugging when a service fails to stop cleanly,
# TimeoutStopFailureMode=abort is set to "crash" services that fail to stop in
# the time allotted. This will cause the service to be terminated with SIGABRT
# and a coredump to be generated.
#
# To undo this configuration change, create a mask file:
# sudo mkdir -p /etc/systemd/system/service.d
# sudo ln -sv /dev/null /etc/systemd/system/service.d/10-timeout-abort.conf

[Service]
TimeoutStopFailureMode=abort
lines 1-25

```

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 20, 2024, 8:58pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/7 "2024-10-20T20:58:21Z")

</div>

> [@vgaetera](#):
>
> ```plaintext
> ExecStart=/path/to/nekoray...
> 
> ```

Which of the files should be executed?

`/usr/lib64/nekoray/nekoray` likely?

![image](https://us1.discourse-cdn.com/fedoraproject/original/3X/e/6/e6997a5f49c07acf60f899b139c30007e6308438.png)

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 20, 2024, 9:18pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/8 "2024-10-20T21:18:06Z")

</div>

I’ve edited this file /etc/systemd/system/nekoray.service with `ExecStart=/usr/lib64/nekoray/nekoray`.

After a reboot, I ran the program and it requests a password.

```plaintext
$ journalctl --no-pager -b -u nekoray.service

Oct 21 00:13:35 x270 systemd[1]: Started nekoray.service - Nekoray service.
Oct 21 00:13:36 x270 nekoray[1452]: qt.qpa.xcb: could not connect to display
Oct 21 00:13:36 x270 nekoray[1452]: qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
Oct 21 00:13:36 x270 nekoray[1452]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
                                    
                                    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Oct 21 00:13:36 x270 systemd[1]: nekoray.service: Main process exited, code=dumped, status=6/ABRT
Oct 21 00:13:36 x270 systemd[1]: nekoray.service: Failed with result 'core-dump'.

```

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 22, 2024, 12:30pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/10 "2024-10-22T12:30:50Z")

</div>

Thanks.

I’ll try creating a sudo cronjob for Nekoray and will get back here if I succeed.

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 27, 2024, 11:26pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/12 "2024-10-27T23:26:32Z")

</div>

Do you find it odd that Nekoray needs sudo privileges at all?

---

<div class="post-metadata">

**Author:** ![Espionage724](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/espionage724/32/6543_2.png) [@Espionage724](https://discussion.fedoraproject.org/u/Espionage724)\
**Post date:** [October 27, 2024, 11:34pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/13 "2024-10-27T23:34:52Z")

</div>

I’m kind of curious why they have an executable in `lib64` and seemingly the whole file structure there 😛

I hope whatever that is has limited SELinux contexts! Not entirely sure how much that would matter with root though, and agree it doesn’t sound like a 3rd-party proxy manager would need root (I imagine it should be fine to set user-side network conf once you’re logged-in), unless you want it _definitely_ system-wide?

I don’t know what Nekoray is exactly but it doesn’t sound like it needs nor should ever have system-wide root access.

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 27, 2024, 11:48pm UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/14 "2024-10-27T23:48:56Z")

</div>

It is an open source VPN client. Apparently developed in China. My uninformed guess is that, yes, it is supposed to take over all the traffic system-wide.

---

<div class="post-metadata">

**Author:** ![caveman](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/caveman/32/41971_2.png) [@caveman](https://discussion.fedoraproject.org/u/caveman)\
**Post date:** [October 28, 2024, 8:39am UTC](https://discussion.fedoraproject.org/t/starting-specific-program-with-sudo/134229/15 "2024-10-28T08:39:02Z")

</div>

P.S. It is in two Fedora COPRs. Not sure if those things get revised at all.
