mirror of
https://github.com/troglobit/finit.git
synced 2026-10-30 12:50:34 +00:00
Merge branch 'master' of cmatsuoka@helllabs.org:git/eeepc
This commit is contained in:
commit
dbdf8ccc72
3 files changed
+28
-20
No files matched your search
+15
-20
@@ -89,6 +89,7 @@ THE SOFTWARE.
|
|||||||
#define LINE_SIZE 1024
|
#define LINE_SIZE 1024
|
||||||
#define CMD_SIZE 256
|
#define CMD_SIZE 256
|
||||||
#define USERNAME_SIZE 16
|
#define USERNAME_SIZE 16
|
||||||
|
#define HOSTNAME_SIZE 32
|
||||||
|
|
||||||
void shutdown(int);
|
void shutdown(int);
|
||||||
void signal_handler(int);
|
void signal_handler(int);
|
||||||
@@ -102,7 +103,8 @@ static void build_cmd(char *cmd, char *x, int len)
|
|||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
c = cmd + strlen(cmd);
|
c = cmd + strlen(cmd);
|
||||||
for (l = 0; x && *x && *x != ' ' && l < len; l++)
|
for (; *x && (*x == ' ' || *x == '\t'); x++);
|
||||||
|
for (l = 0; *x && *x != ' ' && *x != '\t' && l < len; l++)
|
||||||
*c++ = *x++;
|
*c++ = *x++;
|
||||||
*c = 0;
|
*c = 0;
|
||||||
if (debug)
|
if (debug)
|
||||||
@@ -119,15 +121,13 @@ int main()
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
struct sigaction sa, act;
|
struct sigaction sa, act;
|
||||||
char *x;
|
|
||||||
sigset_t nmask, nmask2;
|
sigset_t nmask, nmask2;
|
||||||
char username[USERNAME_SIZE];
|
char username[USERNAME_SIZE] = DEFUSER;
|
||||||
|
char hostname[HOSTNAME_SIZE] = "eviltwin";
|
||||||
char cmd[CMD_SIZE];
|
char cmd[CMD_SIZE];
|
||||||
|
|
||||||
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
|
puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")");
|
||||||
|
|
||||||
strncpy(username, DEFUSER, 16);
|
|
||||||
|
|
||||||
chdir("/");
|
chdir("/");
|
||||||
umask(022);
|
umask(022);
|
||||||
|
|
||||||
@@ -179,10 +179,7 @@ int main()
|
|||||||
char *x;
|
char *x;
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
fgets(line, LINE_SIZE, f);
|
fgets(line, LINE_SIZE, f);
|
||||||
|
chomp(line);
|
||||||
i = strlen(line);
|
|
||||||
if (i && line[i - 1] == '\n')
|
|
||||||
line[i - 1] = 0;
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
printf("conf: %s\n", line);
|
printf("conf: %s\n", line);
|
||||||
@@ -198,18 +195,17 @@ int main()
|
|||||||
build_cmd(username, x, USERNAME_SIZE);
|
build_cmd(username, x, USERNAME_SIZE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (MATCH_CMD(line, "host ", x)) {
|
||||||
|
*hostname = 0;
|
||||||
|
build_cmd(hostname, x, HOSTNAME_SIZE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (MATCH_CMD(line, "module ", x)) {
|
if (MATCH_CMD(line, "module ", x)) {
|
||||||
strcpy(cmd, "/sbin/modprobe ");
|
strcpy(cmd, "/sbin/modprobe ");
|
||||||
build_cmd(cmd, x, CMD_SIZE);
|
build_cmd(cmd, x, CMD_SIZE);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCH_CMD(line, "host ", x)) {
|
|
||||||
*cmd = 0;
|
|
||||||
build_cmd(cmd, x, CMD_SIZE);
|
|
||||||
sethostname(cmd, strlen(cmd));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
@@ -303,14 +299,13 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((f = fopen("/etc/hostname", "r")) != NULL) {
|
if ((f = fopen("/etc/hostname", "r")) != NULL) {
|
||||||
fgets(line, LINE_SIZE, f);
|
fgets(hostname, HOSTNAME_SIZE, f);
|
||||||
if ((x = strchr(line, 0x0a)) != NULL)
|
chomp(hostname);
|
||||||
*x = 0;
|
|
||||||
|
|
||||||
sethostname(line, strlen(line));
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sethostname(hostname, strlen(hostname));
|
||||||
|
|
||||||
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -157,4 +157,16 @@ int run_parts(char *dir, ...)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other convenience functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
void chomp(char *s)
|
||||||
|
{
|
||||||
|
char *x;
|
||||||
|
|
||||||
|
if ((x = strchr((s), 0x0a)) != NULL)
|
||||||
|
*x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
int makepath (char *);
|
int makepath (char *);
|
||||||
void ifconfig (char *, char *, char *, int);
|
void ifconfig (char *, char *, char *, int);
|
||||||
void copyfile (char *, char *, int);
|
void copyfile (char *, char *, int);
|
||||||
|
void chomp (char *);
|
||||||
|
|
||||||
#ifdef BUILTIN_RUNPARTS
|
#ifdef BUILTIN_RUNPARTS
|
||||||
int run_parts (char *, ...);
|
int run_parts (char *, ...);
|
||||||
|
|||||||
Reference in new issue
Block a user