Run through indent, use /* */ style comments instead of //

This commit is contained in:
Glenn L McGrath 2002-08-22 13:12:40 +00:00
parent f853db54f9
commit b37367aa77

View File

@ -59,7 +59,7 @@ static int config_ok;
#define CONFIG_FILE "/etc/busybox.conf"
// applets [] is const, so we have to define this "override" structure
/* applets [] is const, so we have to define this "override" structure */
struct BB_suid_config {
struct BB_applet *m_applet;
@ -72,9 +72,9 @@ struct BB_suid_config {
static struct BB_suid_config *suid_config;
#endif // CONFIG_FEATURE_SUID_CONFIG
#endif /* CONFIG_FEATURE_SUID_CONFIG */
#endif // CONFIG_FEATURE_SUID
#endif /* CONFIG_FEATURE_SUID */
@ -157,7 +157,7 @@ void run_applet_by_name(const char *name, int argc, char **argv)
#ifdef CONFIG_FEATURE_SUID_CONFIG
// check if u is member of group g
/* check if u is member of group g */
static int ingroup ( uid_t u, gid_t g )
{
struct group *grp = getgrgid ( g );
@ -180,7 +180,7 @@ static int ingroup ( uid_t u, gid_t g )
void check_suid ( struct BB_applet *applet )
{
uid_t ruid = getuid ( ); // real [ug]id
uid_t ruid = getuid ( ); /* real [ug]id */
uid_t rgid = getgid ( );
#ifdef CONFIG_FEATURE_SUID_CONFIG
@ -194,29 +194,29 @@ void check_suid ( struct BB_applet *applet )
if ( sct ) {
mode_t m = sct-> m_mode;
if ( sct-> m_uid == ruid ) // same uid
if ( sct-> m_uid == ruid ) /* same uid */
m >>= 6;
else if (( sct-> m_gid == rgid ) || ingroup ( ruid, sct-> m_gid )) // same group / in group
else if (( sct-> m_gid == rgid ) || ingroup ( ruid, sct-> m_gid )) /* same group / in group */
m >>= 3;
if (!( m & S_IXOTH )) // is x bit not set ?
if (!( m & S_IXOTH )) /* is x bit not set ? */
error_msg_and_die ( "You have no permission to run this applet!" );
if (( sct-> m_mode & ( S_ISGID | S_IXGRP )) == ( S_ISGID | S_IXGRP )) { // *both* have to be set for sgid
if (( sct-> m_mode & ( S_ISGID | S_IXGRP )) == ( S_ISGID | S_IXGRP )) { /* *both* have to be set for sgid */
if ( setegid ( sct-> m_gid ))
error_msg_and_die ( "BusyBox binary has insufficient rights to set proper GID for applet!" );
}
else
setgid ( rgid ); // no sgid -> drop
setgid ( rgid ); /* no sgid -> drop */
if ( sct-> m_mode & S_ISUID ) {
if ( seteuid ( sct-> m_uid ))
error_msg_and_die ( "BusyBox binary has insufficient rights to set proper UID for applet!" );
}
else
setuid ( ruid ); // no suid -> drop
setuid ( ruid ); /* no suid -> drop */
}
else { // default: drop all priviledges
else { /* default: drop all priviledges */
setgid ( rgid );
setuid ( ruid );
}
@ -239,7 +239,7 @@ void check_suid ( struct BB_applet *applet )
error_msg_and_die ( "This applet requires root priviledges!" );
}
else if ( applet-> need_suid == _BB_SUID_NEVER ) {
setgid ( rgid ); // drop all priviledges
setgid ( rgid ); /* drop all priviledges */
setuid ( ruid );
}
}
@ -259,11 +259,11 @@ int parse_config_file ( void )
suid_config = 0;
// is there a config file ?
/* is there a config file ? */
if ( stat ( CONFIG_FILE, &st ) == 0 ) {
// is it owned by root with no write perm. for group and others ?
/* is it owned by root with no write perm. for group and others ? */
if ( S_ISREG( st. st_mode ) && ( st. st_uid == 0 ) && (!( st. st_mode & ( S_IWGRP | S_IWOTH )))) {
// that's ok .. then try to open it
/* that's ok .. then try to open it */
f = fopen ( CONFIG_FILE, "r" );
if ( f ) {
@ -289,7 +289,7 @@ int parse_config_file ( void )
if ( c == '[' ) {
p = strchr ( buffer, ']' );
if ( !p || ( p == ( buffer + 1 ))) // no matching ] or empty []
if ( !p || ( p == ( buffer + 1 ))) /* no matching ] or empty [] */
parse_error ( "malformed section header" );
*p = 0;
@ -297,21 +297,21 @@ int parse_config_file ( void )
if ( strcasecmp ( buffer + 1, "SUID" ) == 0 )
section = 1;
else
section = -1; // unknown section - just skip
section = -1; /* unknown section - just skip */
}
else if ( section ) {
switch ( section ) {
case 1: { // SUID
case 1: { /* SUID */
int l;
struct BB_applet *applet;
p = strchr ( buffer, '=' ); // <key>[::space::]*=[::space::]*<value>
p = strchr ( buffer, '=' ); /* <key>[::space::]*=[::space::]*<value> */
if ( !p || ( p == ( buffer + 1 ))) // no = or key is empty
if ( !p || ( p == ( buffer + 1 ))) /* no = or key is empty */
parse_error ( "malformed keyword" );
l = p - buffer;
while ( isspace ( buffer [--l] )) { } // skip whitespace
while ( isspace ( buffer [--l] )) { } /* skip whitespace */
buffer [l+1] = 0;
@ -322,20 +322,20 @@ int parse_config_file ( void )
sct-> m_next = suid_config;
suid_config = sct;
while ( isspace ( *++p )) { } // skip whitespace
while ( isspace ( *++p )) { } /* skip whitespace */
sct-> m_mode = 0;
switch ( *p++ ) {
case 'S': sct-> m_mode |= S_ISUID; break;
case 's': sct-> m_mode |= S_ISUID; // no break
case 's': sct-> m_mode |= S_ISUID; /* no break */
case 'x': sct-> m_mode |= S_IXUSR; break;
case '-': break;
default : parse_error ( "invalid user mode" );
}
switch ( *p++ ) {
case 's': sct-> m_mode |= S_ISGID; // no break
case 's': sct-> m_mode |= S_ISGID; /* no break */
case 'x': sct-> m_mode |= S_IXGRP; break;
case 'S': break;
case '-': break;
@ -350,7 +350,7 @@ int parse_config_file ( void )
default : parse_error ( "invalid other mode" );
}
while ( isspace ( *++p )) { } // skip whitespace
while ( isspace ( *++p )) { } /* skip whitespace */
if ( isdigit ( *p )) {
sct-> m_uid = strtol ( p, &p, 10 );
@ -386,7 +386,7 @@ int parse_config_file ( void )
}
break;
}
default: // unknown - skip
default: /* unknown - skip */
break;
}
}
@ -398,7 +398,7 @@ int parse_config_file ( void )
}
}
}
return 0; // no config file or not readable (not an error)
return 0; /* no config file or not readable (not an error) */
pe_label:
fprintf ( stderr, "Parse error in %s, line %d: %s\n", CONFIG_FILE, lc, err );