* PATCH: chown escape for usernames containing .
@ 1999-12-13 11:37 zefram
0 siblings, 0 replies; only message in thread
From: zefram @ 1999-12-13 11:37 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-12-13 11:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-13 11:37 PATCH: chown escape for usernames containing zefram
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).