summaryrefslogtreecommitdiffstats
path: root/systemd/nfs-server-generator.c
diff options
context:
space:
mode:
Diffstat (limited to 'systemd/nfs-server-generator.c')
-rw-r--r--systemd/nfs-server-generator.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
index af8bb52..f47718e 100644
--- a/systemd/nfs-server-generator.c
+++ b/systemd/nfs-server-generator.c
@@ -47,6 +47,8 @@ static int is_unique(struct list **lp, char *path)
l = l->next;
}
l = malloc(sizeof(*l));
+ if (l == NULL)
+ return 0;
l->name = path;
l->next = *lp;
*lp = l;
@@ -112,7 +114,7 @@ int main(int argc, char *argv[])
strcat(path, filebase);
f = fopen(path, "w");
if (!f)
- return 1;
+ exit(1);
fprintf(f, "# Automatically generated by nfs-server-generator\n\n[Unit]\n");
for (i = 0; i < MCL_MAXTYPES; i++) {
@@ -129,6 +131,9 @@ int main(int argc, char *argv[])
}
fstab = setmntent("/etc/fstab", "r");
+ if (!fstab)
+ exit(1);
+
while ((mnt = getmntent(fstab)) != NULL) {
if (strcmp(mnt->mnt_type, "nfs") != 0 &&
strcmp(mnt->mnt_type, "nfs4") != 0)
@@ -138,6 +143,7 @@ int main(int argc, char *argv[])
fprintf(f, ".mount\n");
}
+ fclose(fstab);
fclose(f);
exit(0);