/* -*-c-*-
*
- * $Id: fattr.c,v 1.1 1999/07/26 23:33:56 mdw Exp $
- *
* Handling of file attributes
*
* (c) 1999 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
- * This file is part of the `fw' port forwarder.
+ * This file is part of the `fwd' port forwarder.
*
- * `fw' is free software; you can redistribute it and/or modify
+ * `fwd' is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
- * `fw' is distributed in the hope that it will be useful,
+ *
+ * `fwd' is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
- * along with `fw'; if not, write to the Free Software Foundation,
+ * along with `fwd'; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: fattr.c,v $
- * Revision 1.1 1999/07/26 23:33:56 mdw
- * Support code for new design.
- *
- */
-
-/*----- Header files ------------------------------------------------------*/
-
-#include "config.h"
-
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include <pwd.h>
-#include <grp.h>
-
-#include "conf.h"
-#include "fattr.h"
-#include "scan.h"
+#include "fwd.h"
/*----- Global variables --------------------------------------------------*/
/* --- Gobble an optional `=' sign --- */
+ conf_undelim(sc, 0, ",=+-");
token(sc);
if (sc->t == '=')
token(sc);
if (sc->t != CTOK_WORD)
error(sc, "parse error, expected file mode");
+ conf_undelim(sc, 0, 0);
/* --- If it looks digitlike, read as octal --- */
else {
const char *p;
- unsigned mask = 07777;
+ unsigned mask = 04700;
+ unsigned state = 0;
unsigned or = 1;
/* --- Set the default from the umask --- */
switch (*p) {
case ',': break;
- case 'a': mask = 07777; break;
- case 'u': mask = 04700; break;
- case 'g': mask = 02070; break;
- case 'o': mask = 01007; break;
+ case 'a': mask = (mask & state) | 07777; state = 07777; break;
+ case 'u': mask = (mask & state) | 04700; state = 07777; break;
+ case 'g': mask = (mask & state) | 02070; state = 07777; break;
+ case 'o': mask = (mask & state) | 01007; state = 07777; break;
- case '=': mode &= ~mask; break;
- case '-': or = 0; break;
- case '+': or = 1; break;
+ case '=': mode &= ~mask; /* Drop through */
+ case '+': state = 0; or = 1; break;
+ case '-': state = 0; or = 0; break;
#define APPLY(m) if (or) mode |= ((m) & mask); else mode &= ~((m) & mask);
- case 'r': APPLY(00444); break;
- case 'w': APPLY(00222); break;
- case 'x': APPLY(00111); break;
- case 's': APPLY(06000); break;
- case 't': APPLY(01000); break;
+ case 'r': state = 0; APPLY(00444); break;
+ case 'w': state = 0; APPLY(00222); break;
+ case 'x': state = 0; APPLY(00111); break;
+ case 's': state = 0; APPLY(06000); break;
+ case 't': state = 0; APPLY(01000); break;
#undef APPLY
default: error(sc, "unknown mode character `%c'", *p);