aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-02-21 13:49:41 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-02-21 13:49:41 -0600
commita6cc7f06cf3807a0e0590697e1f14e6ab9055271 (patch)
treea3b1f87315a22b743a5bf35d1e42b68dab01b198 /src/rc
parentc1178c8eebb92c9f3702e981cd4af9ef41f51884 (diff)
rc.c: remove PATH_MAX references
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c
index 110591e4..1f462c66 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -336,26 +336,26 @@ set_krunlevel(const char *level)
return true;
}
-static size_t
-get_krunlevel(char *buffer, int buffer_len)
+static char *get_krunlevel(void)
{
+ char *buffer = NULL;
FILE *fp;
size_t i = 0;
if (!exists(RC_KRUNLEVEL))
- return 0;
+ return NULL;
if (!(fp = fopen(RC_KRUNLEVEL, "r"))) {
eerror("fopen `%s': %s", RC_KRUNLEVEL, strerror(errno));
- return 0;
+ return NULL;
}
- if (fgets(buffer, buffer_len, fp)) {
+ if (getline(&buffer, &i, fp) != -1) {
i = strlen(buffer);
if (buffer[i - 1] == '\n')
buffer[i - 1] = 0;
}
fclose(fp);
- return i;
+ return buffer;
}
static void
@@ -743,7 +743,7 @@ int main(int argc, char **argv)
RC_STRING *service;
bool going_down = false;
int depoptions = RC_DEP_STRICT | RC_DEP_TRACE;
- char krunlevel [PATH_MAX];
+ char *krunlevel = NULL;
char pidstr[10];
int opt;
bool parallel;
@@ -892,7 +892,8 @@ int main(int argc, char **argv)
(strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 &&
strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0))
{
- if (get_krunlevel(krunlevel, sizeof(krunlevel))) {
+ krunlevel = get_krunlevel();
+ if (krunlevel) {
newlevel = krunlevel;
set_krunlevel(NULL);
}