From: zefram@fysh.org
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: chown escape for usernames containing .
Date: Mon, 13 Dec 1999 11:37:53 GMT [thread overview]
Message-ID: <199912131137.LAA05298@mango.dublin.iona.ie> (raw)
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
reply other threads:[~1999-12-13 11:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199912131137.LAA05298@mango.dublin.iona.ie \
--to=zefram@fysh.org \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).