diff options
author | Marcel Telka <marcel.telka@nexenta.com> | 2014-04-26 00:11:24 +0200 |
---|---|---|
committer | Gordon Ross <gwr@nexenta.com> | 2014-04-30 20:55:07 -0400 |
commit | c5953fd0a23d8a0dc9475dfa76ad0dfd07663717 (patch) | |
tree | bed2fcd39846695ded15542d1ce46ac12698e46e | |
parent | 0900f4f20e4cdeb8e5af4ba32aca32d28aeba2f9 (diff) | |
download | illumos-joyent-c5953fd0a23d8a0dc9475dfa76ad0dfd07663717.tar.gz |
4808 libnsl: SI_SRPC_DOMAIN is always defined
Reviewed by: Andy Stormont <AStormont@racktopsystems.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Gordon Ross <gwr@nexenta.com>
-rw-r--r-- | usr/src/lib/libnsl/rpc/getdname.c | 101 |
1 files changed, 6 insertions, 95 deletions
diff --git a/usr/src/lib/libnsl/rpc/getdname.c b/usr/src/lib/libnsl/rpc/getdname.c index 34d2ea22b4..a471117bea 100644 --- a/usr/src/lib/libnsl/rpc/getdname.c +++ b/usr/src/lib/libnsl/rpc/getdname.c @@ -24,6 +24,9 @@ * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ @@ -33,120 +36,28 @@ * California. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Gets and sets the domain name of the system */ -#include "mt.h" -#include "rpc_mt.h" -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/utsname.h> #include <sys/systeminfo.h> -#include <sys/time.h> -#include <syslog.h> - -#ifndef SI_SRPC_DOMAIN -#define use_file -#endif - -#ifdef use_file -char DOMAIN[] = "/etc/domain"; -#endif - -int setdomainname(); - -#ifdef use_file -static char *domainname; -#endif - -extern mutex_t dname_lock; int -getdomainname(name, namelen) - char *name; - int namelen; +getdomainname(char *name, int namelen) { -#ifdef use_file - FILE *domain_fd; - char *line; - - (void) mutex_lock(&dname_lock); - if (domainname) { - (void) strncpy(name, domainname, namelen); - (void) mutex_unlock(&dname_lock); - return (0); - } - - domainname = calloc(1, 256); - if (domainname == NULL) { - syslog(LOG_ERR, "getdomainname : out of memory."); - (void) mutex_unlock(&dname_lock); - return (-1); - } - - if ((domain_fd = fopen(DOMAIN, "r")) == NULL) { - - (void) mutex_unlock(&dname_lock); - return (-1); - } - if (fscanf(domain_fd, "%s", domainname) == NULL) { - (void) fclose(domain_fd); - (void) mutex_unlock(&dname_lock); - return (-1); - } - (void) fclose(domain_fd); - (void) strncpy(name, domainname, namelen); - (void) mutex_unlock(&dname_lock); - return (0); -#else int sysinfostatus; sysinfostatus = sysinfo(SI_SRPC_DOMAIN, name, namelen); return ((sysinfostatus < 0) ? -1 : 0); -#endif } int -setdomainname(domain, len) - char *domain; - int len; +setdomainname(char *domain, int len) { -#ifdef use_file - - FILE *domain_fd; - - (void) mutex_lock(&dname_lock); - if (domainname) - free(domainname); - - if ((domain_fd = fopen(DOMAIN, "w")) == NULL) { - (void) mutex_unlock(&dname_lock); - return (-1); - } - if (fputs(domain, domain_fd) == NULL) { - (void) mutex_unlock(&dname_lock); - return (-1); - } - (void) fclose(domain_fd); - domainname = calloc(1, 256); - if (domainname == NULL) { - syslog(LOG_ERR, "setdomainname : out of memory."); - (void) mutex_unlock(&dname_lock); - return (-1); - } - (void) strncpy(domainname, domain, len); - (void) mutex_unlock(&dname_lock); - return (0); -#else int sysinfostatus; sysinfostatus = sysinfo(SI_SET_SRPC_DOMAIN, - domain, len + 1); /* add null */ + domain, len + 1); /* add null */ return ((sysinfostatus < 0) ? -1 : 0); -#endif } |