Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: chown escape for usernames containing .
- X-seq: zsh-workers 9013
- From: zefram@xxxxxxxx
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: chown escape for usernames containing .
- Date: Mon, 13 Dec 1999 11:37:53 GMT
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Clint Adams wrote:
>> Almost. chown accepts "." to separate username and group, in addition to
>> the POSIX ":". This is the same level of POSIX conformance as GNU chown.
>
>Which is unlike any other chown on the planet.
Except for all the ones that just use ".", which GNU chown is trying to
be compatible with.
> GNU chown would be a
>lot more tolerable if it supported some sort of override to allow
>usernames containing periods;
Yes, it did occur to me that this was a problem.
> such as '--ignore-group' or '::'
>ideas which have been suggested elsewhere.
Like this?
diff -cr ../zsh-/Doc/Zsh/mod_files.yo ./Doc/Zsh/mod_files.yo
*** ../zsh-/Doc/Zsh/mod_files.yo Mon Dec 13 11:25:00 1999
--- ./Doc/Zsh/mod_files.yo Mon Dec 13 11:16:53 1999
***************
*** 17,28 ****
startsitem()
sitem(var(user))(change owner to var(user); do not change group)
sitem(var(user)tt(:))(change owner to var(user); change group to var(user)'s primary group)
sitem(var(user)tt(:)var(group))(change owner to var(user); change group to var(group))
sitem(tt(:)var(group))(do not change owner; change group to var(group))
endsitem()
! In each case, the `tt(:)' may instead be a `tt(.)'.
Each of var(user) and var(group) may be either a username (or group name, as
appropriate) or a decimal user ID (group ID). Interpretation as a name
takes precedence, if there is an all-numeric username (or group name).
--- 17,33 ----
startsitem()
sitem(var(user))(change owner to var(user); do not change group)
+ sitem(var(user)tt(::))(change owner to var(user); do not change group)
sitem(var(user)tt(:))(change owner to var(user); change group to var(user)'s primary group)
sitem(var(user)tt(:)var(group))(change owner to var(user); change group to var(group))
sitem(tt(:)var(group))(do not change owner; change group to var(group))
endsitem()
! In each case, the `tt(:)' may instead be a `tt(.)'. The rule is that
! if there is a `tt(:)' then the separator is `tt(:)', otherwise
! if there is a `tt(.)' then the separator is `tt(.)', otherwise
! there is no separator.
!
Each of var(user) and var(group) may be either a username (or group name, as
appropriate) or a decimal user ID (group ID). Interpretation as a name
takes precedence, if there is an all-numeric username (or group name).
diff -cr ../zsh-/Src/Modules/files.c ./Src/Modules/files.c
*** ../zsh-/Src/Modules/files.c Mon Dec 13 11:25:00 1999
--- ./Src/Modules/files.c Mon Dec 13 11:24:02 1999
***************
*** 628,648 ****
{
struct chownmagic chm;
char *uspec = ztrdup(*args), *p = uspec;
chm.nam = nam;
if(func == BIN_CHGRP) {
chm.uid = -1;
goto dogroup;
}
! if(*p == ':' || *p == '.') {
chm.uid = -1;
p++;
goto dogroup;
} else {
struct passwd *pwd;
- char *end = strchr(p, ':');
- if(!end)
- end = strchr(p, '.');
if(end)
*end = 0;
pwd = getpwnam(p);
--- 628,649 ----
{
struct chownmagic chm;
char *uspec = ztrdup(*args), *p = uspec;
+ char *end;
chm.nam = nam;
if(func == BIN_CHGRP) {
chm.uid = -1;
goto dogroup;
}
! end = strchr(uspec, ':');
! if(!end)
! end = strchr(uspec, '.');
! if(end == uspec) {
chm.uid = -1;
p++;
goto dogroup;
} else {
struct passwd *pwd;
if(end)
*end = 0;
pwd = getpwnam(p);
***************
*** 666,671 ****
--- 667,674 ----
return 1;
}
chm.gid = pwd->pw_gid;
+ } else if(p[0] == ':' && !p[1]) {
+ chm.gid = -1;
} else {
struct group *grp;
dogroup:
END
Messages sorted by:
Reverse Date,
Date,
Thread,
Author