LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 06-07-2012, 05:13 PM   #1
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
How to make lp and lpr run as if I were root


I'm running Ubuntu 10.04. If I or applications that use lp or lpr try to print, an Unauthorized error is received. I've posted the error on launchpad.

I'd like to know how to get lp and lpr to run as if I or the applications I'm running were root. lp and lpr run fine, if I preface them with sudo.

I've tried setuid with no luck.

What else can I try?

Thanks.

Last edited by cmnorton; 06-07-2012 at 05:14 PM. Reason: Punctuation
 
Old 06-08-2012, 01:37 PM   #2
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1
Posts: 4,872

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
As root, or use sudo to chmod lp and lpr. The command would look like this.

chmod 777 /usr/bin/lp and do the same for lpr. You have to verify the path to the files, or change directory to the files.
 
Old 06-08-2012, 02:35 PM   #3
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
Need lp and lpr to act as if root ran them

Your suggestion works, but applications can't do that running as me. I need these two commands to act as if root ran them. I've tried setuid and it does not work or I was (probably the reason) not setting
the uid bit correctly.
 
Old 06-08-2012, 02:56 PM   #4
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1
Posts: 4,872

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
Quote:
but applications can't do that running as me.
What? once the permissions are set, they stay there. Apps don't have to change anything.
 
Old 06-08-2012, 04:07 PM   #5
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
I can print as root, not as me

I can print as root. I want to set the permissions in such a way, that my using lp or lpr is as if I were logged in as root.
 
Old 06-08-2012, 05:09 PM   #6
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1
Posts: 4,872

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
What groups does your use ID blong to? Open a konsole and run the command 'id youruser' ( without the quotes ) and post the results. You probably need to add yourself to the lp group, or what ever group ubuntu uses for printing.
 
Old 06-08-2012, 07:15 PM   #7
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
Will try lp group

am already part of lpadmin, though.
 
Old 06-11-2012, 09:36 PM   #8
Mike_P
LQ Newbie
 
Registered: Apr 2012
Posts: 15

Rep: Reputation: Disabled
Quote:
Originally Posted by cmnorton View Post
I've tried setuid and it does not work or I was (probably the reason) not setting
the uid bit correctly.
Must be root to do this.

To make an application run as root for any user. For example type

Code:
sudo chmod 4777 path-to-file
When you run ls -l to view the file, the execute bit x for root is replaced by a letter s
-rwsrwxrwx

Also, check if lp and lpr are not symlinks to the actual program(s)

Last edited by Mike_P; 06-11-2012 at 09:38 PM.
 
Old 06-12-2012, 03:42 AM   #9
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,734
Blog Entries: 12

Rep: Reputation: 457Reputation: 457Reputation: 457Reputation: 457Reputation: 457
do NOT I repeat do NOT chmow chown or in any other way change the file properties


Your user should be in lpadmin, lp, and scanner groups

Quote:
$ groups
craig lp cdrom floppy sudo audio dip video plugdev users netdev lpadmin powerdev scanner debian-tor
DebuggingPrintingProblems - Ubuntu Wiki - https://wiki.ubuntu.com/DebuggingPrintingProblems
Printers - Community Ubuntu Documentation - https://help.ubuntu.com/community/Printers
NetworkPrintingWithUbuntu - Community Ubuntu Documentation - https://help.ubuntu.com/community/Ne...tingWithUbuntu
 
Old 06-12-2012, 09:57 AM   #10
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
Even with group privs, does not work

Thanks for answering. My Ubuntu system does not have a scanner group, but cnorton is in lp and lpadmin.
I still can't print a file at the command line.

Quote:
Originally Posted by craigevil View Post
do NOT I repeat do NOT chmow chown or in any other way change the file properties


Your user should be in lpadmin, lp, and scanner groups



DebuggingPrintingProblems - Ubuntu Wiki - https://wiki.ubuntu.com/DebuggingPrintingProblems
Printers - Community Ubuntu Documentation - https://help.ubuntu.com/community/Printers
NetworkPrintingWithUbuntu - Community Ubuntu Documentation - https://help.ubuntu.com/community/Ne...tingWithUbuntu
 
Old 06-12-2012, 10:01 AM   #11
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
Tried setting UID

Thanks for answering. lp and lpr are not symlinks. I tried setting the UID per your instructions, and I get the same error.
Quote:
Originally Posted by Mike_P View Post
Must be root to do this.

To make an application run as root for any user. For example type

Code:
sudo chmod 4777 path-to-file
When you run ls -l to view the file, the execute bit x for root is replaced by a letter s
-rwsrwxrwx

Also, check if lp and lpr are not symlinks to the actual program(s)
 
Old 06-12-2012, 10:40 AM   #12
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1
Posts: 4,872

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
With the printer plugged in to USB port, and turned on, please run this command, copy and paste the results here.

'ls -l /dev/usb/lp* /dev/bus/usb/*/*' run the command without the quotes, just what is between them.
 
Old 06-12-2012, 03:31 PM   #13
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
No local printers

Thanks for responding. I've got network printers. One's an SMB. I'll gladly grab whatever you need an post it.
Quote:
Originally Posted by camorri View Post
With the printer plugged in to USB port, and turned on, please run this command, copy and paste the results here.

'ls -l /dev/usb/lp* /dev/bus/usb/*/*' run the command without the quotes, just what is between them.
 
  


Reply

Tags
cups, lp, lpr


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Make Apt-Get Always Run as Root LXer Syndicated Linux News 0 03-03-2009 10:50 PM
how to make cifs run as root cdavidson Linux - Newbie 7 03-19-2005 11:32 PM
How do I make a command run as root at boot up under Fedora 3? versaulis Linux - Software 5 02-10-2005 07:22 PM
Gnome and root AND lpr is crooked movitto Linux - General 3 09-08-2004 11:36 AM
lpr as non-root Syllogism Linux - Software 0 09-09-2003 09:26 AM


All times are GMT -5. The time now is 02:23 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration