LinuxQuestions.org
Visit Jeremy's Blog.
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 07-01-2006, 08:56 PM   #1
polemon
Member
 
Registered: Jun 2005
Distribution: Fedora 18, Ubuntu 11.10, Ubuntu Server 11.10, DamnSmallLinux 3.4.4, FreeDOS 1.1, OpenBSD 5.0
Posts: 194

Rep: Reputation: 31
how to run applications as a differnet user?


Hi!

I've got my IRC server along with services running nicely on my machine.

But the problem is, either I can run it as root, which is somewhat dangerous, due to permissions that come along with it. Or, I can run it as myself. But then I have to log in, and that's not what I want.

My idea is pretty much taken from the Apache world of servers:
The service has it's own username and group, under which it runs, and has access to it's files.

But I couldn't find a how-to, in any of my Linux books, adressing this problem.

Could someone give me a tip, how to make applications run as a different user? Say, it's started by root, but then changes to 'ircd' or something.

cheers

--polemon
 
Old 07-01-2006, 09:22 PM   #2
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
Code:
su ircd -c ircd
# syntax: su <username> -c <command>
 
Old 07-02-2006, 09:12 AM   #3
polemon
Member
 
Registered: Jun 2005
Distribution: Fedora 18, Ubuntu 11.10, Ubuntu Server 11.10, DamnSmallLinux 3.4.4, FreeDOS 1.1, OpenBSD 5.0
Posts: 194

Original Poster
Rep: Reputation: 31
Cool! thanx!

One more thing though:
Can I add users without a login shell, password and home directory, directly with adduser?
 
Old 07-02-2006, 12:32 PM   #4
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
you can use useradd without certain switches it won't create a ~ directory, and you can change it's entry in /etc/passwd for the shell to be /bin/false or whatever you want.
 
Old 07-02-2006, 12:46 PM   #5
vls
Member
 
Registered: Jan 2005
Location: The grassy knoll
Distribution: Slackware,Debian
Posts: 192

Rep: Reputation: 31
Quote:
Originally Posted by polemon
Could someone give me a tip, how to make applications run as a different user? Say, it's started by root, but then changes to 'ircd' or something.
That behavior needs to be written as part of the program.

I believe if you add your ircd user, chown ircd to user ircd and then use the setuid bit on the binary it will run as ircd.(Sorry for all the repetition. And lousy spelling.)

Last edited by vls; 07-10-2006 at 06:23 PM.
 
Old 07-02-2006, 05:40 PM   #6
polemon
Member
 
Registered: Jun 2005
Distribution: Fedora 18, Ubuntu 11.10, Ubuntu Server 11.10, DamnSmallLinux 3.4.4, FreeDOS 1.1, OpenBSD 5.0
Posts: 194

Original Poster
Rep: Reputation: 31
actually, I tryed being /sbin/nologin or /bin/false, but then I can't run programs with the su command, the solution cs-cam suggested.
the shell is /bin/sh now, and unfortunatelly, I _can_ log in, but only while being root with the su command. A Password is not given, I have a "*" (asterisc) in the place where the password should go, in the shadow file (standart for system-users).
It works that way, and I think I'm gonna leave it like that.

It's not the fully professional way, though.
I'd definately want to be the shell /sbin/nologin, and force the program to change it's UID afterwards.
Are you sure this can't be done with a shell command?

cheers,

--polemon
 
Old 07-10-2006, 06:13 PM   #7
polemon
Member
 
Registered: Jun 2005
Distribution: Fedora 18, Ubuntu 11.10, Ubuntu Server 11.10, DamnSmallLinux 3.4.4, FreeDOS 1.1, OpenBSD 5.0
Posts: 194

Original Poster
Rep: Reputation: 31
Solved:
I wrote a shellscript for the /etc/init.d and /etc/rcX.d/ directory hierarchy.
There you can use the functions, provided by /etc/init.d/funtions shellscript, one of those is called "daemon". It supports starting processes as a different user, by simply calling bash with that user. Since it is root in the beginning, bash obeys this directive.

easy.

The /etc/init.d/ structure, is a Red-Hat thing. The tool chkconfig works together with that. Don't know how to solve it on other systems, except by writing your own startup script with some algorythms from the functions-script.

Thanks for your help anyways.

--polemon
 
  


Reply

Tags
daemon, irc, ircd, user, userid, username


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
How do I run these applications after installation? stugi Suse/Novell 3 03-30-2006 05:08 PM
ns-2, run my own applications over it? hedpe Linux - Networking 2 02-12-2006 04:38 PM
User account goes totally bonk, no applications can run anymore. Baldorg Linux - General 5 07-28-2005 12:51 PM
last shows root login using tty2 terminal from differnet user machines maheshs Linux - Security 1 04-17-2005 03:12 PM
Cannot run X applications as root jplev22 Slackware 8 02-15-2004 11:39 PM


All times are GMT -5. The time now is 03:53 AM.

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