unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* PID file ownership and group
@ 2011-09-20  8:18 Lee Hambley
  2011-09-20 18:03 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Lee Hambley @ 2011-09-20  8:18 UTC (permalink / raw)
  To: mongrel-unicorn

I'm using unicorn in an environment with /very/ strict permissions (one might so as far as to say that the sysadmin is being too careful) and I've observed that when starting Unicorn via `upstart` (runs as root) with unicorn.rb configured to suid and sguid, the logs and other files are correctly owned by `selected user:group` but the pidfile is owned by root:root. Owing to very restrictive unmasking and other permissions, this file is not readable by any lower-level users, and thus one has to be root to read the pidfile.

What's the logic here, is it a bug, an oversight or an intentional design, naturally one can use `ps` or any other number of ways to get a pid, so protecting the pidfile doesn't seem like a security concern/

Of course this is somewhat academic, as one must be root to signal the process anyway, but I'll cross that particular bridge when I come to it!

Lee
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PID file ownership and group
  2011-09-20  8:18 PID file ownership and group Lee Hambley
@ 2011-09-20 18:03 ` Eric Wong
       [not found]   ` <FF8DE317-F98B-4D13-B8D7-95B4B922A6BF@me.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2011-09-20 18:03 UTC (permalink / raw)
  To: unicorn list; +Cc: Lee Hambley

Lee Hambley <leehambley@me.com> wrote:
> I'm using unicorn in an environment with /very/ strict permissions
> (one might so as far as to say that the sysadmin is being too careful)
> and I've observed that when starting Unicorn via `upstart` (runs as
> root) with unicorn.rb configured to suid and sguid, the logs and other
> files are correctly owned by `selected user:group` but the pidfile is
> owned by root:root. Owing to very restrictive unmasking and other
> permissions, this file is not readable by any lower-level users, and
> thus one has to be root to read the pidfile.
> 
> What's the logic here, is it a bug, an oversight or an intentional
> design, naturally one can use `ps` or any other number of ways to get
> a pid, so protecting the pidfile doesn't seem like a security concern/

I didn't think of it until now, but I don't think it's necessary to
expose.  With the exception of creating Unix domain sockets, unicorn
always respects the umask given to it, and unicorn only changes
permissions inside worker processes.

Also, nginx (where unicorn draws many design elements from) does not
change the permissions of the pid file, either.

> Of course this is somewhat academic, as one must be root to signal the
> process anyway, but I'll cross that particular bridge when I come to
> it!

Yeah, there's no point in knowing it unless you can send signals to it.

-- 
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PID file ownership and group
       [not found]   ` <FF8DE317-F98B-4D13-B8D7-95B4B922A6BF@me.com>
@ 2011-09-20 20:23     ` Eric Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2011-09-20 20:23 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Lee Hambley

Lee Hambley <leehambley@me.com> wrote:
> > Also, nginx (where unicorn draws many design elements from) does not
> > change the permissions of the pid file, either.
> > 
> >> Of course this is somewhat academic, as one must be root to signal the
> >> process anyway, but I'll cross that particular bridge when I come to
> >> it!
> > 
> > Yeah, there's no point in knowing it unless you can send signals to it.

> Surely though, with the pid being root:root when started via upstart
> (and the restrictive u+rwx/g+rwx/o-) permissions enforced by my umask,
> it would still make sense to own the pid to `unicorn:projectname` -
> given that you can signal your own processes, then the "unicorn" user
> should be able to read the pid?

Not really, the pid file is only for the master process.  The master
always stays as the user it is started as (root in your case).  Only the
worker processes have their user:group changed and they can't signal the
master after the change.

> (Although, that said, most implementations I have seen of "monitors"
> for unicorn seem to use `ps` to get the pid, which does seem somewhat
> wasteful)

Strange, wouldn't the monitors /not/ daemonize and thus be able to use
the pid of the process they started?

> Thanks for getting back to me so quickly on here Eric, with Github I'd
> almost forgotten that mailing lists work!

No problem.  Signups/logins/passwords bother me, and I also dislike
99.999% of HTML, images, and JavaScript on the web; so I'll be sticking
to mailing lists :)

-- 
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-20 20:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-20  8:18 PID file ownership and group Lee Hambley
2011-09-20 18:03 ` Eric Wong
     [not found]   ` <FF8DE317-F98B-4D13-B8D7-95B4B922A6BF@me.com>
2011-09-20 20:23     ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).