274
submitted 7 months ago by renzev@lemmy.world to c/linuxmemes@lemmy.world

Credit for the answer used in the right panel: https://serverfault.com/a/841150

top 50 comments
sorted by: hot top controversial new old
[-] mholiv@lemmy.world 90 points 7 months ago

When you hate something so much you have to find weird corner cases to support your views. Even then the way described isn’t how someone who knows that they are doing would do.

The best way for an unprivileged user to manage a service is for that user to run it. That way you inherit the correct permissions / acls / selinux contexts.

The command to do so is:

systemctl --user start the_service.service

[-] sorrybookbroke@sh.itjust.works 13 points 7 months ago* (last edited 7 months ago)

What if multiple users have to manage that service?

Edit: nvrmnd, pretty sure the runnit solution won't allow this either, your answer is correct. What about while the service is already running? Wouldn't your solution require a restart?

[-] mholiv@lemmy.world 14 points 7 months ago

If the service is already running it has to be stopped as a system service and run as a user service. In order to ensure that the service inherits all the correct permissions / acls / se linux policies the service needs to be launched from the limited permissions context.

With the systemd approach you’re not just passing a control handle around. You’re ensuring the process is running under an appropriate security context.

If you want to let multiple users manage the user systems service, I would probably go with sudo and systemd user files. You could create a group which has sudo access etc. The important idea is that an unprivileged user controls an unprivileged service.

[-] renzev@lemmy.world 4 points 7 months ago

With the systemd approach

What about this makes it "the systemd approach"? runit supports user services too. These are just two different tasks that are needed in different contexts. Sometimes what you need is to "pass a control handle around" to a privileged service. And sometimes you need to actually make a service unprivileged.

[-] renzev@lemmy.world 6 points 7 months ago* (last edited 7 months ago)

pretty sure the runnit solution won’t allow this either

I'm no expert, but I think you could make a special group, set the supervise directory to be owned by that group, and add all relevant users to that group? Either way, as I explained in a different reply, running the service as a user vs letting that user control a root service are completely different things, and one is not always a substitute for the other.

[-] MashedTech@lemmy.world 4 points 7 months ago* (last edited 7 months ago)

A generic stack overflow answer:

Do you REALLY need multiple users to manage that service? Maybe it's better to have multiple instances of that service and.... (This goes on and on)

[-] renzev@lemmy.world 11 points 7 months ago

have to find weird corner cases

Lol. Lmao even. I needed to do this because I wanted to learn the miryoku keyboard layout , and I wanted a way to quickly switch between Miryoku and standard QWERTY. The best way to do this that I could come up with was to bind a special key on my keyboard to toggle kmonad on and off. So I wrote a service for kmonad and gave my user permission to manage it. Running kmonad as my user wouldn't work, because kmonad needs root to create a virtual input device.

Luckily, I am running Void, so the solution was a single well-documented command. Out of curiosity I decided to take a look at what this would look like on systemd distros, leading to this meme. Honestly, I had to do a double take by the time the guy started talking about Javascript.

I feel kind of useless typing this out because you're just gonna ignore it anyway. In my post, I am talking about needing to do X. Your response is "why are you doing X, you should do Y". Why am I not surprised that you're a systemd user? Do you also use Gnome by any chance?

[-] mholiv@lemmy.world 20 points 7 months ago

Hey. There is no reason to feel useless. Everyone has value. And the best part about Linux is that we all can make our own choices. If people hate systemd they don’t have to use it. That’s ok. Void linux I think is actually a pretty cool distro. It reminds me of the BSDs for some reason.

I use systemd because I like how it works and I think it’s well designed. As for desktops I am a huge fan of sway. Gnome isn’t bad on a laptop or tablet though. What do you use?

[-] renzev@lemmy.world 3 points 7 months ago

I'm on bspwm right now, but I've been thinking of switching to wayland (in particular, hyprland). I've got nothing against gnome BTW. I have a friend with one of those laptops that turns into a tablet by flipping the keyboard to the back, and he also says Gnome is the only DE that "just works" for touchscreen, even though he uses KDE on his main laptop and desktop.

How are things on wayland by the way? From what I understand, it has partial support for running X11 apps, right? Do you use any X11 apps, or were you able to find wayland-native counterparts for everything?

[void] reminds me of the BSDs for some reason

I've heard this comparison a lot, though I don't know what it means, since I've never used BSD haha. Maybe I should give BSD a try sometime.

And the best part about Linux is that we all can make our own choices

Amen to that!

[-] redcalcium@lemmy.institute 2 points 7 months ago* (last edited 7 months ago)

How are things on wayland by the way? From what I understand, it has partial support for running X11 apps, right? Do you use any X11 apps, or were you able to find wayland-native counterparts for everything?

Most of the time, you wouldn't even notice if an app is using xwayland or native wayland... except for apps written with electron/chromium embedded framework (chromium, steam client, spotify, vscode, etc). They're pretty glitchy on xwayland so you'll have to figure out if they accept arguments to use wayland natively, but not all of them support wayland natively yet.

[-] renzev@lemmy.world 1 points 7 months ago

That's good to hear. I try to avoid electron apps (I just use the website version instead), but thanks for the tip anyway!

[-] bear@slrpnk.net 5 points 7 months ago* (last edited 7 months ago)

Your response is "why are you doing X, you should do Y"

Because they're right, you shouldn't do X. I know that's not a satisfying answer for most people to hear, but it's often one people need to hear.

If the process must run as root, then giving a user direct and unauthenticated control over it is a security vulnerability. You've created a quick workaround for your issue, and to be clear it is unlikely to realistically cause you problems individually, but on a larger scale that becomes a massive issue. A better solution is required rather than recommend everybody create a hole in their security like yours in order to do this thing.

If this is something that unprivileged users reasonably want to control, then this control should be possible unprivileged, or at least with limited privilege, not by simply granting permanent total control of a root service.

This is ultimately an upstream issue more than anything else.

[-] redcalcium@lemmy.institute 3 points 7 months ago

Wait, aren't most desktop environment support switching keyboard layout these days? For example, gnome can do that with super+space or via the language switcher in the top bar. Using a user service to do this seems overkill.

load more comments (1 replies)
[-] Shareni@programming.dev 3 points 7 months ago

and I wanted a way to quickly switch between Miryoku and standard QWERTY. The best way to do this that I could come up with was to bind a special key on my keyboard to toggle kmonad on and off.

You couldn't think of to use layers?

[-] renzev@lemmy.world 1 points 7 months ago

Well that would require learning the kmonad config syntax, and I was just looking for a quick solution... but yeah, adding a QWERTY layer is a better solution in the long term, I'll probably do that some time

[-] Vilian@lemmy.ca 42 points 7 months ago

he's trying to run the service as a user without run sudo, good luck trying that with runit

[-] mexicancartel@lemmy.dbzer0.com 2 points 7 months ago
[-] Vilian@lemmy.ca 2 points 7 months ago

he don't want to log as root, so a root shell isn't what he want

[-] bjoern_tantau@swg-empire.de 39 points 7 months ago* (last edited 7 months ago)

And people who like systemd just thought of the first part of the answer which is exactly what the asker ended up doing.

Which is basically the same as the runit way while putting everything in the user's directory.

[-] possiblylinux127@lemmy.zip 29 points 7 months ago
[-] nick@midwest.social 18 points 7 months ago

Correct. I fucking hate systemd.

[-] possiblylinux127@lemmy.zip 22 points 7 months ago

Ok, just stop complaining. Almost everyone else disagrees and most of the community doesn't even know that there is a different init system. Systemd was widely accepted 6 years ago and we have moved on.

The good news is that you don't have to use it. The bad news is pretty much everyone expects you to be using it.

[-] nick@midwest.social 11 points 7 months ago
[-] renzev@lemmy.world 3 points 7 months ago

Don't bother arguing with systemd bots. They spent time and effort learning the ins and outs of their overcomplicated init system, so naturally when someone suggests that there is a simpler solution, they interpret it as a personal attack.

load more comments (1 replies)
[-] anyhow2503@lemmy.world 26 points 7 months ago

Big news (from 2017): debian held back software features because someone doesn't like the new way of doing things. Let's blame systemd for this unprecedented case.

What's wrong with giving access to the specific sudo command, as suggested in the other answers?

[-] traches@sh.itjust.works 23 points 7 months ago

How is chown-R someuser different from systemctl—user?

[-] brian@programming.dev 24 points 7 months ago

one is giving the permission to manage the system service to a specific user, the other is running the service as the current user so they have permission to manage it by default

[-] Sanctus@lemmy.world 13 points 7 months ago

I'm gonna fuck up my desktop now breaking away from systemd

[-] Darorad@lemmy.world 7 points 7 months ago

Yeah, I would switch off, but it just doesn't seem worth the effort for something I rarely interact with.

[-] gravitas_deficiency@sh.itjust.works 11 points 7 months ago

If it’s providing you the functionality you want using an overhead you’re fine with, there’s no reason to change it.

[-] duviobaz 11 points 7 months ago

I'm using Debian without ever having been involved in the init-wars. What's wrong with Systemd and why should i not use it?

[-] renzev@lemmy.world 4 points 7 months ago* (last edited 7 months ago)

If you've never had a reason to not use it, then it's fine to continue using it. Systemd has been shown to be more or less stable, fast, and secure. The reason I don't like it is because it makes simple things really complicated. Some examples:

  • The meme
  • u/phoenixz@lemmy.ca example with sshd
  • Distros that use systemd init also seems to prefer using other systemd components as well. So you can get caught in weird situations where one task is spread across two different systems (e.g. systemd timers vs cron, systemd-elogind vs acpid)

If none of these sound familiar, then switching to a non-systemd distro likely won't make your life easier. But if you do, then it might be worth considering.

[-] anarkatten@lemmy.ml 4 points 7 months ago

I'd like to know too, a ELI5 version if possible. Somethingsomething monolithic, but what does that actually mean for me as an end user?

[-] redcalcium@lemmy.institute 7 points 7 months ago

Which one looks more enterprisey and ensure your job security?

[-] renzev@lemmy.world 2 points 7 months ago

your job security

I think I finally understand why systemd bots defend their init system so aggressively.

[-] WalnutLum@lemmy.ml 7 points 7 months ago

And how do you do this in gnu shepherd?

You don't!

[-] NeatNit@discuss.tchncs.de 7 points 7 months ago* (last edited 7 months ago)

I'm out of the loop. The answer that references "one person's personal opinion" is from 2017, and the context it links to is from 2016. Surely things have changed since then, right?

.. Right?

(I'm genuinely asking, I've got no idea)

Edit: I just checked on Linux Mint 21.3. It's still on the same version as back then, 0.105. Well, Debian is nothing if not sable!

[-] ozymandias117@lemmy.world 3 points 7 months ago

Bookworm looks to be on version 122, so as downstream distros update to newer Debian versions, it should be updated now

load more comments (4 replies)
load more comments (1 replies)
[-] teddy2021@sh.itjust.works 3 points 7 months ago

Gonna be honest, never heard of running before this. Briefly considered switching before OPs presentation in the comments turned me off. I don't want to associate with his/ her mind of weirdo, they aren't fun.

load more comments (6 replies)
[-] onlinepersona@programming.dev 3 points 7 months ago

Runit, making systems easily pwnable since 2004 🎉

  • Step 1: Make a system service run as root
  • Step 2: Give service a runlevel that starts it at boot
  • Step 3: Make the file modifiable by a normal user
  • Step 4: ???
  • Step 5: pwned

Wow much philosopy. Is great. Incredible chievement. Very pressive!

Anti Commercial-AI license

[-] LordCrom@lemmy.world 2 points 7 months ago

Does resolve.d let me use DHCP address with a manually set DNS server yet?

[-] DriftinGrifter 3 points 7 months ago

netwok and resolve d are cancer

[-] mojo_raisin@lemmy.world 2 points 7 months ago

DJB is a genius

[-] hector@sh.itjust.works 2 points 7 months ago

Guys I only used SystemD and I didn’t know you could use anything else lol stop hating I never had any problems!

[-] yournamehere@lemm.ee 2 points 7 months ago

systemd is for the weak. red hat and lennart are just shit.

load more comments (2 replies)
load more comments
view more: next ›
this post was submitted on 13 Apr 2024
274 points (100.0% liked)

linuxmemes

21410 readers
729 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack members of the community for any reason.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, and wants to interject for a moment. You can stop now.
  •  

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't fork-bomb your computer.

    founded 1 year ago
    MODERATORS