/*
+ * Copyright (c) 2008-2014, Simon Schubert <2@0x2c.org>.
* Copyright (c) 2008 The DragonFly Project. All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
- * by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>.
+ * by Simon Schubert <2@0x2c.org>.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
const char *
hostname(void)
{
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 255
+#endif
static char name[HOST_NAME_MAX+1];
static int initialized = 0;
char *s;
void
setlogident(const char *fmt, ...)
{
- char tag[50];
+ static char tag[50];
snprintf(tag, sizeof(tag), "%s", logident_base);
if (fmt != NULL) {
va_end(ap);
}
+ errno = oerrno;
if (*outs != 0) {
syslog(LOG_ERR, "%s: %m", outs);
fprintf(stderr, "%s: %s: %s\n", getprogname(), outs, strerror(oerrno));
set_username(void)
{
struct passwd *pwd;
- uid_t uid;
- uid = getuid();
- if (check_username(getlogin(), uid))
+ useruid = getuid();
+ if (check_username(getlogin(), useruid))
return;
- if (check_username(getenv("LOGNAME"), uid))
+ if (check_username(getenv("LOGNAME"), useruid))
return;
- if (check_username(getenv("USER"), uid))
+ if (check_username(getenv("USER"), useruid))
return;
- pwd = getpwuid(uid);
+ pwd = getpwuid(useruid);
if (pwd != NULL && pwd->pw_name != NULL && pwd->pw_name[0] != '\0') {
- if (check_username(pwd->pw_name, uid))
+ if (check_username(pwd->pw_name, useruid))
return;
}
- snprintf(username, sizeof(username), "uid=%ld", (long)uid);
+ snprintf(username, sizeof(username), "uid=%ld", (long)useruid);
}
void