/srv/irclogs.ubuntu.com/2022/07/15/#ubuntu-server.txt

=== scoobydoob is now known as scoobydoo
patdk-lapseems overly complex, why not use the ipv6 space that is already mapped for ipv601:03
=== scoobydoob is now known as scoobydoo
PeGaSuShello guys! so, I'm opening a public BNC service and I'd need that the `bnc` user to be able to edit the netplan config file to add the IPs from where each ZNC would would connect (the bindhost IP) and also use `netplan apply`. what would the the best way to achieve this?07:36
rfmPeGaSuS, sudo was designed to allow fine tuned control like this. best thing I can think of is to write a couple scripts, one that adds an IP to the list in netplan, one that does the netplan apply, and then use sudoers to grant the bnc user the right to run them.07:44
PeGaSuSthe IP adding and applying would be done via this script would be automatically done by this script (it does work as root):https://0bin.xyz/paste/r4atJxjljPgw0+U8#mtq4cs5vxypSUewVsjVI+ubRdmk7J2WE3HEOSNCEKSS07:44
PeGaSuSright. I'll need to read about how to give permissions to certain commands via sudoers file07:45
PeGaSuSI'm wondering how accurate is this: https://kifarunix.com/run-only-specific-commands-with-sudo-in-linux/#:~:text=So%20it%20is%20possible%20to,under%20the%20%2Fetc%2Fsudoers.07:48
rfmPeGaSuS, certainly looks ok to me at a first glance07:48
rfmPeGaSuS, you might want to grind through the sudoers(6) man page to make sure you know what you are doing before you make the edits07:50
PeGaSuSI mean, I kinda know how things works but I'm always afraid of messing up. but there's no success without failure :)07:51
PeGaSuSthis looks nice too: https://serverfault.com/questions/206827/sudoers-config-to-allow-edit-of-files-in-particular-directory-and-children07:54
PeGaSuSI'll get into it as soon as I arrive home and see what I can cook ;)07:54
tomreynPeGaSuS: If those are user supplied inputs (specifically, theUser), and you don't fully trust them, some form of input validation is probably also a good idea. Bash isn't ideal for this, but even there it's possible to some degree. E.g. you wouldn't want someone to take the username of "`echo '...' >> /root/.ssh/authorized_keys`" or similar. 08:47
PeGaSuSthose are supplied inputs but only by the staff (those that will have access to the shell account). that's why I want to limit them to edit the netplan file and apply the new config10:48
PeGaSuSI do trust the people that "work" with me but we never know ¯\_(ツ)_/¯10:49
PeGaSuScan someone point me to "for stupid people" tutorial about setfacl?20:21
sarnoldhah, cute, our wiki page doesn't seem to have examples of adding facls.. https://help.ubuntu.com/community/FilePermissionsACLs20:22
sarnoldah, well, it does, but for groups. maybe that makes sense..20:23
PeGaSuSI'm relly having a brain stroke today -_-20:23
sarnoldaha, "Creating ACLs" on https://linuxgazette.net/152/prestia.html  has nice short example :)20:24
ahasenackI feel sad that ACLs are not leveraged as much in normal linux systems20:37
ahasenacksame thing for capabilities20:37
ahasenacksquid is one package I know of which drops the suid bit on an executable in favor of capabilities20:38
ahasenackhttps://pastebin.ubuntu.com/p/w3vMNhQgws/20:38
sarnoldit's *really* unfortunate that packages have to go through this kind of hassle in maintainer scripts to use them20:40
sarnoldbut systemd service files make it easy to grant just specific caps to a program, and then only when started in the expected environment, rather than when run by any old process that can find it in the filesystem20:41
sarnoldof course, other systemd things means even the caps aren't nearly as important as they used to be -- when systemd can do socket activation, or change uid and gid for the program, or set resource limits, etc etc etc20:41
PeGaSuSpls tell me that this only allow user root and user bnc to edit the `/etc/netplan/50-cloud-init.yaml`: https://0bin.xyz/paste/kYVSNeMUA25q8d3E#6NP1I+PvF8UhuTj91qELUECvsgO33dCOq25PnwJNb8f20:42
sarnoldPeGaSuS: yeah, that's what it looks like; bnc can also *execute* the file, which might be surprising20:44
ahasenackI don't even know what that squid pinger is used for, I'm guessing it's started by squid itself, and will thus inherit the capabilities and such from the squid main systemd service file20:45
ahasenackI just checked and the main squid apparmor file has rules because of pinger, instead of switching to a child profile20:46
sarnoldit's been ages, but I think the pinger is used when you've got a network of squids acting in concert to provide multi-level caching20:46
PeGaSuSI tried only rw but that gave me a `./userip.sh: line 4: /etc/netplan/50-cloud-init.yaml: Permission denied`. the script is: https://0bin.xyz/paste/rXqqzQpZ7MRYz+LE#Zz9g+xMzK9R5tOD9mn7Sdkxt4UyfymkdAfwCrNWFG2x20:48
sarnoldPeGaSuS: the directory needs the 'x', the file doesn't20:48
sarnoldPeGaSuS: so, what happens when someone uses the username `touch /tmp/hello` or $(shutdown -r now) or similar?20:49
blackboxswPeGaSuS: as non-root user I don't think you can append output via >> some-root-readonlyfile20:49
sarnoldblackboxsw: https://0bin.xyz/paste/kYVSNeMUA25q8d3E#6NP1I+PvF8UhuTj91qELUECvsgO33dCOq25PnwJNb8f has some setfacl things20:50
PeGaSuSoh. so, `setfacl -m u:bnc:rwx /etc/netplan` and `setfacl -m u:bnc:rw /etc/netplan`? also, the username that i pass as `theUser` must be a valid IRC nickname with only [a-zA-Z0-9]20:51
PeGaSuSerm.. `setfacl -m u:bnc:rw /etc/netplan/50-cloud-init.yaml`?20:51
sarnoldPeGaSuS: I think some "" around the variables in the script would help; I'm a big fan of belts and suspenders :)20:52
sarnoldPeGaSuS: I like those setfacls more, yeah20:52
blackboxswahh sarnold sry did't have context there20:53
sarnoldblackboxsw: yeah, it'd be easy to miss :) hehe20:53
PeGaSuSsarnold: I have the $theUser and $theIP variables inside quotes though xD20:53
sarnoldPeGaSuS: I'm rusty enough on shell scripts that this scares me regardless :)20:54
PeGaSuSwell guys, the important is that all works as expected so I can give staff the password for the shell account so we can start our public ZNC service20:56
PeGaSuSthanks for all the help folks :D20:56
sarnoldthanks for giving each user their own ipv6 :) that's a big help in dealing with abuse :)20:57
PeGaSuSthats exactly the major reason to give each user their own IPv6 address (especially since I own a /64 block) along with proper identd responses :D20:58
PeGaSuSI'm a network owner and I know how hard is to fight with spam and abusers. although changing the network policy to only allow TLS connections help dropping drone attacks and such21:00

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!