Commit 765ddab2 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(param): Moved to server-config.c.

(create_status): Write the name of the user as the first line of
	the status file.  With luck, that is a valid email address.
parent da35f06e
/*
* $Id: komrunning.c,v 1.1 1999/04/17 00:10:42 ceder Exp $
* $Id: komrunning.c,v 1.2 1999/04/17 21:54:48 ceder Exp $
* Copyright (C) 1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -27,6 +27,7 @@
# include <config.h>
#endif
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -45,8 +46,6 @@
#include "param.h"
#include "pidfile.h"
struct kom_par param;
static void
usage(const char *arg0)
{
......@@ -60,6 +59,20 @@ create_status(const char *arg0)
{
FILE *fp;
int saved_errno;
struct passwd *pwent;
const char *user;
user = getenv("USER");
if (user == NULL)
{
pwent = getpwuid(getuid());
if (pwent != NULL)
user = pwent->pw_name;
}
if (user == NULL)
user = "root";
fp = fopen(param.status_file, "w");
if (fp == NULL)
......@@ -71,7 +84,7 @@ create_status(const char *arg0)
exit(1);
}
if (fputs("shutdown\n", fp) == EOF)
if (fputs(user, fp) == EOF || putc('\n', fp) == EOF)
{
saved_errno = errno;
fprintf(stderr, "%s: writing to ", arg0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment