sysctl: warn when separators are repeated
For some reason sysctl earlier allowed quite strange separators. % sysctl kernel./.pty.nr kernel./.pty.nr = 6 % sysctl kernel///pty//////////nr kernel...pty..........nr = 6 This commit does not disallow that sort of constructs, but will warn about them. In future disallowing these might be reasonable thing to do. % sysctl kernel./.pty.nr sysctl: separators should not be repeated: ./.pty.nr kernel./.pty.nr = 6 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
9f89e336c3
commit
8795154eac
5
sysctl.c
5
sysctl.c
@ -63,11 +63,16 @@ static char *pattern;
|
||||
static int pattern_match(const char *string, const char *pattern);
|
||||
|
||||
static void slashdot(char *restrict p, char old, char new){
|
||||
int warned = 1;
|
||||
p = strpbrk(p,"/.");
|
||||
if(!p) return; /* nothing -- can't be, but oh well */
|
||||
if(*p==new) return; /* already in desired format */
|
||||
while(p){
|
||||
char c = *p;
|
||||
if((*(p+1) == '/' || *(p+1) == '.') && warned) {
|
||||
warnx(_("separators should not be repeated: %s"), p);
|
||||
warned = 0;
|
||||
}
|
||||
if(c==old) *p=new;
|
||||
if(c==new) *p=old;
|
||||
p = strpbrk(p+1,"/.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user