> Basically, the emacsserver process lives on a socket which 
> contains the 
> uid of the server. Thus we have a primitive rendevous 
> protocol. There's 
> really no way out of this. You could conceivably craft up 
> some sort of 
> alias that invokes sudo emacsclient with the correct uid, but 
> then the 
> resulting file would end up written by (probably) the wrong user. I 
> suspect that's not what you want.

I did a little test by executing gnuclient with real user ID as root and effective 
user ID as my normal user. It allows the connection, and allows editing of the file!! 
However, just as was mentioned above, the file's permissions change to your user 
instead of keeping it as root.  Here's the test with some comments:

% cat exc.c
#include <unistd.h>

int main(int argc, char** argv)
{
    if (argc < 2)
    {
        fprintf(STDERR_FILENO, "Usage: %s command [args]", argv[0]);
        exit(1);
    }

    execvp(argv[1], argv+1);
}

% ls -l exc
-rws------    1 myuser   users        4983 Apr 17 12:55 exc
(notice exc is suid to myuser)
% su
Password:

root@mymachine
[Wed Apr 17] [/home/myuser/test] ls -l tempy
-rw-r--r--    1 root     root            5 Apr 17 12:42 tempy
(notice tempy is writable only by root)

root@mymachine
[Wed Apr 17] [/home/myuser/test] ./exc gnuclient tempy &
[1] 25715

root@mymachine
[Wed Apr 17] [/home/myuser/test] ps -e -o pid,ruser,euser,args | grep gnuclient
25715 root     myuser   gnuclient tempy <==(notice ruser=root and euser=myuser)
25719 root     root     grep gnuclient

Here I edit the file and save it, with the caveat that I have to specify Alt-X 
toggle-read-only because emacs thinks it is read-only (due to permissions) even 
thought it's not.

root@mymachine
[Wed Apr 17] [/home/myuser/test] ls -l tempy
-rw-r--r--    1 myuser   mygroup        28 Apr 17 13:14 tempy
(notice the permissions of tempy have changed to myuser and mygroup instead of keeping 
them as root)

In short:
(1) Compile exc.c into exc as regular user
(2) chmod 4700 exc
(only do #1 and #2 once and store exc somewhere you can access it always)
(3) ./exc gnuclient filename
(4) Alt-x toggle-read-only. Edit and write file as you please
(5) have to change the permission bits back to original

for #5, an emacs guru might be able to tell you how to do that right in emacs instead 
of outside emacs. Hope that helps  . . .

*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to