LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-22-2021, 05:24 PM   #1
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Question Package management using sudo


Hi all,

While tinkering with sudoers files, I was wondering what would be the caveats of using sudo to manage packages.

install/upgrade/remove seems to be ok

slackpkg too

sbopkg could fail for packages that need full login as would some SlackBuilds I believe. In these cases, would the -i option do the job ?

I've did some man pages reading but can't get a satisfaying answer...
The goal is to fire some commands that can last long without letting open a root terminal.... Especially usefull when updating a batch of laptops...

Thanks for your inputs !
 
Old 02-22-2021, 10:05 PM   #2
pghvlaans
Member
 
Registered: Jan 2021
Distribution: Slackware64 {15.0,-current}, FreeBSD, stuff on QEMU
Posts: 459

Rep: Reputation: 366Reputation: 366Reputation: 366Reputation: 366
sudo -i uses the root path, which includes /usr/sbin and /sbin, so it would allow for using slackpkg, makepkg, etc. Using the full path to the binary (e.g. sudo /sbin/makepkg ...) is another way to do it.

I suppose it would also be possible to edit a non-root user's path to include /usr/sbin and /sbin; no comment on whether that's a good idea or not.
 
Old 02-22-2021, 10:34 PM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,714

Rep: Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734Reputation: 2734
Package installation has nothing directly to do with sudo, sudo is for privilage escalation or identity fudging. Using sudo for package installation comes in handy when proper installation requires root or superuser access rights that your user account (you should hope) lacks.
 
Old 02-22-2021, 11:57 PM   #4
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Never had any problems with sudo for system updates here. My setup is a shell script /usr/local/sbin/update-system (with chmod 750):
Code:
#!/usr/bin/env bash

echo "Checking for updates..."

if ! slackpkg check-updates; then
    slackpkg -batch='on' update
    slackpkg install-new
    slackpkg upgrade-all
    slackpkg clean-system
fi
in a file in /etc/sudoers.d/
Code:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Cmnd_Alias SAFE = /usr/local/sbin/update-system
## allow with no password
myuser ALL=(ALL) NOPASSWD: SAFE
and in my user's shell aliases:
Code:
alias up='sudo update-system'
So 'up' triggers the whole thing, no passwords to type, but no system-wide sudo access or anything dodgy like that.

But if I was doing pkgtools stuff (install/upgrade/removepkg etc), I'd not be bothered with "sudo" before every command, and would prefer "su" in that case.

Last edited by drgibbon; 02-22-2021 at 11:58 PM.
 
2 members found this post helpful.
Old 02-23-2021, 09:49 AM   #5
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
I've been using sudo on my systems for years. I've never had any problems with permissions or login settings, but I also added sbin locations with my user's PATH.

Code:
if [ "`id -u`" = "0" -o "`id -u`" = "1000" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi
The "full login" is pretty much tied to the PATH of the user running the commands. If your user has access to all the PATH locations, then a full login won't be an issue.

You can also set the PATH in visudo, which will override the local PATH, but this may have problems if you have programs that set additional PATH locations in /etc/profile.d/.

Code:
## Uncomment to use a hard-coded PATH instead of the user's to find commands
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 
1 members found this post helpful.
Old 02-23-2021, 10:19 AM   #6
hitest
Guru
 
Registered: Mar 2004
Location: Canada
Distribution: Void, Slackware, Debian, OpenBSD
Posts: 7,345

Rep: Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746
I like and use visudo to set-up sudo for my regular user. I use sudo for my package management and administrative needs.
 
1 members found this post helpful.
Old 02-23-2021, 11:06 AM   #7
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407

Original Poster
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Thank you all for your inputs.

Never thought using sudo for pkg management but know I will use that with some handy aliases in the .bashrc :-)

Last edited by Tonus; 02-23-2021 at 11:08 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] No package 'x11' found No package 'xext' found No package 'xdamage' found No package 'xfixes' found No package 'x11-xcb' found Jigsaw Linux From Scratch 14 02-23-2021 08:35 PM
which package management system / distribution is the simplest to package for? Siljrath Linux - General 2 10-25-2014 08:08 PM
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
LXer: Simple Package management with Synaptic Package Manager LXer Syndicated Linux News 0 12-05-2006 06:33 PM
Using Package Archive style package management mugwump84 Linux From Scratch 3 08-25-2005 05:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration