[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cfengine doesn't warn about problems in "mode="
From: |
Martin Jost |
Subject: |
cfengine doesn't warn about problems in "mode=" |
Date: |
Thu, 07 Mar 2002 16:34:37 +0100 |
Hello,
this based on cfengine2.0.b4 + my previous "mode_patch"
cfengine doesn't warn about some problems in "mode="
Here are the cases:
(Old: Behaviour before patch
New: Behaviour after patch)
-------------------------------------------------
/home/jost/cfengine/dummy mode=u=755 owner=jost group=users
action=fixplain
===>
Old:
cfengine:lasagne: /home/jost/cfengine/dummy had permission 777,
changed it to 755
New:
cf:lasagne:/home/jost/cfengine/cfagent.conf:29: Symbolic and numeric
filemodes mixed within expression
-------------------------------------------------
-------------------------------------------------
/home/jost/cfengine/dummy mode=u=rw,755 owner=jost group=users
action=fixplain
===>
Old:
cfengine:lasagne: /home/jost/cfengine/dummy had permission 777,
changed it to 655
New:
lasagne:/home/jost/cfengine/cfagent.conf:29: Warning: Symbolic and
numeric form for modes mixed
-------------------------------------------------
There has been another problem with too big nemeric constants used in
mode=.
The patch for this slipped into my "mode_patch" by accident.
Here are the logs:
prototypes.h:
SetMask() takes an additional argument 'affected' carrying a bit-mask
of the affected bits.
(see log entry for modes.c for details)
cf.defs.h:
'enum modesort' added; records type (numerical or symbolic) for
mode-Strings
modes.c:
Some pathologic cases didn't raise an error or warning.
E.g.:
Mixing symbolic and numerical mode within an expression (error)
[u=755]
Mixing symbolic and numerical mode (warning, but handled correctly by
interpretation from left to right)
[u=rw,755]
Variables added:
- sort
sort (numerical or symbolic) of mode which is just processed
Used to trigger an error in CheckModeState() when both sorts are
mixed up
- found_sort
sort (numerical or symbolic); set whenever ',' is found
used to trigger a warning when both sorts a used in combination
CheckModeState() now takes two additional arguments of Type 'enum mode
sort'
An error is raised if both are != 'unkown' and _not_ equal
('Symbolic and numeric filemodes mixed within expression')
Called in addition after one of '+-=' have been found.
BTW, I stumbled over another problem:
cfagent reports:
"Saving the setuid log in /var/cfengine/cfagent..log"
And it really does this ! (Note the two '.' in the filename)
The patch is attached. (Apply in cfengine...-Dir with 'patch -p1 <
checkmode_patch')
Martin
Index: cfengine/src/cf.defs.h
diff -c cfengine/src/cf.defs.h:1.1.1.3 cfengine/src/cf.defs.h:1.1.1.3.2.1
*** cfengine/src/cf.defs.h:1.1.1.3 Wed Mar 6 12:37:23 2002
--- cfengine/src/cf.defs.h Thu Mar 7 15:31:31 2002
***************
*** 955,960 ****
--- 955,967 ----
which
};
+ enum modesort
+ {
+ unkown,
+ numeric,
+ symbolic
+ };
+
/*******************************************************************/
typedef char flag;
Index: cfengine/src/modes.c
diff -c cfengine/src/modes.c:1.1.1.3.2.1 cfengine/src/modes.c:1.1.1.3.2.2
*** cfengine/src/modes.c:1.1.1.3.2.1 Wed Mar 6 19:10:55 2002
--- cfengine/src/modes.c Thu Mar 7 15:48:17 2002
***************
*** 37,45 ****
char *modestring;
mode_t *plusmask, *minusmask;
! { int affected = 0, value = 0, gotaction;
! char action = '=', *sp;
! enum modestate state = who;
if (modestring == NULL)
{
--- 37,49 ----
char *modestring;
mode_t *plusmask, *minusmask;
! { char *sp;
! int affected = 0, value = 0, gotaction;
! char action = '=';
! enum modestate state = who;
! enum modesort found_sort = unkown; /* Already found "sort" of mode */
! enum modesort sort = unkown; /* Sort of started but not yet finished mode */
!
if (modestring == NULL)
{
***************
*** 55,74 ****
{
switch (*sp)
{
! case 'a': CheckModeState(who,state,*sp);
affected |= 07777;
break;
! case 'u': CheckModeState(who,state,*sp);
affected |= 04700;
break;
! case 'g': CheckModeState(who,state,*sp);
affected |= 02070;
break;
! case 'o': CheckModeState(who,state,*sp);
affected |= 00007;
break;
case '+':
--- 59,82 ----
{
switch (*sp)
{
! case 'a': CheckModeState(who,state,symbolic,sort,*sp);
affected |= 07777;
+ sort = symbolic;
break;
! case 'u': CheckModeState(who,state,symbolic,sort,*sp);
affected |= 04700;
+ sort = symbolic;
break;
! case 'g': CheckModeState(who,state,symbolic,sort,*sp);
affected |= 02070;
+ sort = symbolic;
break;
! case 'o': CheckModeState(who,state,symbolic,sort,*sp);
affected |= 00007;
+ sort = symbolic;
break;
case '+':
***************
*** 77,105 ****
{
yyerror("Too many +-= in mode string");
}
action = *sp;
state = which;
gotaction = true;
break;
! case 'r': CheckModeState(which,state,*sp);
value |= 0444 & affected;
break;
! case 'w': CheckModeState(which,state,*sp);
value |= 0222 & affected;
break;
! case 'x': CheckModeState(which,state,*sp);
value |= 0111 & affected;
break;
! case 's': CheckModeState(which,state,*sp);
value |= 06000 & affected;
break;
! case 't': CheckModeState(which,state,*sp);
value |= 01000;
break;
case '0':
--- 85,121 ----
{
yyerror("Too many +-= in mode string");
}
+
+ CheckModeState(who,state,symbolic,sort,*sp);
action = *sp;
state = which;
gotaction = true;
+ sort = symbolic;
break;
! case 'r': CheckModeState(which,state,symbolic,sort,*sp);
value |= 0444 & affected;
+ sort = symbolic;
break;
! case 'w': CheckModeState(which,state,symbolic,sort,*sp);
value |= 0222 & affected;
+ sort = symbolic;
break;
! case 'x': CheckModeState(which,state,symbolic,sort,*sp);
value |= 0111 & affected;
+ sort = symbolic;
break;
! case 's': CheckModeState(which,state,symbolic,sort,*sp);
value |= 06000 & affected;
+ sort = symbolic;
break;
! case 't': CheckModeState(which,state,symbolic,sort,*sp);
value |= 01000;
+ sort = symbolic;
break;
case '0':
***************
*** 109,115 ****
case '4':
case '5':
case '6':
! case '7': state = which;
affected = 07777; /* TODO: Hard-coded; see below */
sscanf(sp,"%o",&value);
if (value > 07777) /* TODO: Hardcoded !
--- 125,134 ----
case '4':
case '5':
case '6':
! case '7': CheckModeState(who,state,numeric,sort,*sp);
! sort = numeric;
! gotaction = true;
! state = which;
affected = 07777; /* TODO: Hard-coded; see below */
sscanf(sp,"%o",&value);
if (value > 07777) /* TODO: Hardcoded !
***************
*** 129,134 ****
--- 148,159 ----
case ',':
SetMask(action,value,affected,plusmask,minusmask);
+ if (found_sort != unkown && found_sort != sort)
+ {
+ Warning("Symbolic and numeric form for modes mixed");
+ }
+ found_sort = sort;
+ sort = unkown;
action = '=';
affected = 0;
value = 0;
***************
*** 146,151 ****
--- 171,180 ----
}
SetMask(action,value,affected,plusmask,minusmask);
+ if (found_sort != unkown && found_sort != sort)
+ {
+ Warning("Symbolic and numeric form for modes mixed");
+ }
Debug1("[PLUS=%o][MINUS=%o]\n",*plusmask,*minusmask);
return;
***************
*** 158,167 ****
/*********************************************************/
! void CheckModeState(stateA,stateB,ch)
enum modestate stateA;
int stateB;
char ch;
{
--- 187,197 ----
/*********************************************************/
! void CheckModeState(stateA,stateB,sortA,sortB,ch)
enum modestate stateA;
int stateB;
+ enum modesort sortA, sortB;
char ch;
{
***************
*** 169,174 ****
--- 199,209 ----
{
sprintf(VBUFF,"Mode string constant (%c) used out of context",ch);
yyerror(VBUFF);
+ }
+
+ if ((sortA != unkown) && (sortB != unkown) && (sortA != sortB))
+ {
+ yyerror("Symbolic and numeric filemodes mixed within expression");
}
return;
}
Index: cfengine/src/prototypes.h
diff -c cfengine/src/prototypes.h:1.1.1.3.2.1
cfengine/src/prototypes.h:1.1.1.3.2.2
*** cfengine/src/prototypes.h:1.1.1.3.2.1 Wed Mar 6 19:11:53 2002
--- cfengine/src/prototypes.h Thu Mar 7 15:49:31 2002
***************
*** 601,607 ****
/* modes.c */
void ParseModeString ARGLIST((char *modestring, mode_t *plusmask, mode_t
*minusmask));
! void CheckModeState ARGLIST((enum modestate stateA, int stateB, char ch));
void SetMask ARGLIST((char action, int value, int affected, mode_t *p, mode_t
*m));
/* mount.c */
--- 601,608 ----
/* modes.c */
void ParseModeString ARGLIST((char *modestring, mode_t *plusmask, mode_t
*minusmask));
! void CheckModeState ARGLIST((enum modestate stateA, int stateB, \
! enum modesort modeA, enum modesort modeB, char
ch));
void SetMask ARGLIST((char action, int value, int affected, mode_t *p, mode_t
*m));
/* mount.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- cfengine doesn't warn about problems in "mode=",
Martin Jost <=