jed-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: jed doesn't maintain group owner


John E. Davis wrote:
V01D <phreakuencies@xxxxxxxxx> wrote:
[root@pris kickstart]# chgrp nobody config.xml
[root@pris kickstart]# ls -l config.xml
-rw-rw-r-- 1 v01d nobody 735 2006-07-28 20:56 config.xml
[root@pris kickstart]# exit
[v01d@pris kickstart]$ jed config.xml             (edit & save here)
[v01d@pris kickstart]$ ls -l config.xml
-rw-rw-r-- 1 v01d users 735 2006-07-28 20:57 config.xml

Another user reported this problem and I have been able to reproduce
it.  Unfortunately, I do not believe there is anything I can do about
it.  Unless you are a member of the group that you are trying to
preserve, or running with the proper privileges, the chown system call
will fail.  In fact, here is what the man page says about chown:

    These  system calls change the owner and group of the file specified by
    path or by  fd.   Only  a  privileged  process  (Linux:  one  with  the
    CAP_CHOWN  capability)  may change the owner of a file.  The owner of a
    file may change the group of the file to any group of which that  owner
    is  a  member.  A privileged process (Linux: with CAP_CHOWN) may change
    the group arbitrarily.

You can put

   BACKUP_BY_COPYING = 1;

in your .jedrc file.  Then jed will create a backup file by coping it,
and the overwrite the new file, preserving its group id.  However, the
group will not be preserved for the backup file.  For example, you
should see something like:

  [v01d@pris kickstart]$ ls -l config.xml*
  -rw-rw-r-- 1 v01d nobody 735 2006-07-28 20:56 config.xml
  -rw-rw-r-- 1 v01d users 735 2006-07-28 20:57 config.xml~

--John

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


But why would you need to call chown()? If I open a file, write/read it and then close it, the permissions remain intact. I mean, if I compile this on C++:

#include <iostream>
#include <cstdio>

int main(void) {
        FILE* f = fopen("test.file", "r+");
        char a = '@';
        fwrite(&a, 1, 1, f);
        fclose(f);
}

and create a file test.file with touch with the following permissions:
-rw-rw-r-- 1 v01d nobody 1 2006-08-03 16:50 test.file

you can see that it doesn't change them:

[v01d@pris ~]$ g++ -o test.out test.cpp
[v01d@pris ~]$ ls -l test.file
-rw-rw-r-- 1 v01d nobody 1 2006-08-03 16:52 test.file
[v01d@pris ~]$ ./test.out
[v01d@pris ~]$ ls -l test.file
-rw-rw-r-- 1 v01d nobody 1 2006-08-03 16:52 test.file
[v01d@pris ~]$ cat test.file
@[v01d@pris ~]$

Although I don't know how jed handles files.

Matt.

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]