[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: unix svn hooks, permissions / sudo?

From: timotheus <timotheus_at_tstotts.net>
Date: 2007-07-22 20:34:05 CEST

"aaron smith" <beingthexemplarylists@gmail.com> writes:

> Hey all,
>
> I've got a script I'm trying to execute in my hook script. Is there
> anyway to get around permisisons issues? currently when it runs I get
> a "password:" prompt back in the log files. It's probably prompting
> for root password. If I don't use "sudo" then I don't get the prompt
> but I get a "permission denied". The script is writing a file to
> another virtual host document root..
>
> any ideas?
>
> thanks all..

Two very different approaches that might work for you.

(1)

# /etc/sudoers
# user apache may run this command without a password prompt
apache ALL=(root) NOPASSWD: /bin/bash /var/www/my_script.sh

(2)

/* ~/tmp/run_as_myuser.c */

#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>

int main (void) {
  /* UID and GID of my personal user */
  uid_t my_uid = 501;
  gid_t my_gid = 501;

  /* run as myuser with a full login shell */
  setreuid(my_uid, my_uid);
  setregid(my_gid, my_gid);
  setenv("HOME", "/home/myuser", 1);
  execl("/bin/bash", "bash", "--login", "-c", "bash /home/myuser/public_html/my_script.sh", (const char*) NULL);
  return(EXIT_FAILURE);
}

/* To compile:
   gcc run_as_myuser.c -o run_as_myuser
   chown myuser:myuser run_as_myuser
   chmod u=rxs,g=xs,o=x run_as_myuser
*/

Regards,
-timotheus

  • application/pgp-signature attachment: stored
Received on Sun Jul 22 20:33:21 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.