Avoid using HOST_NAME_MAX directly and use sysconf(_SC_HOST_NAME_MAX)
instead.
This commit is contained in:
1
MANIFEST
1
MANIFEST
@@ -91,6 +91,7 @@ lib/util/fnmatch.c
|
|||||||
lib/util/getaddrinfo.c
|
lib/util/getaddrinfo.c
|
||||||
lib/util/getcwd.c
|
lib/util/getcwd.c
|
||||||
lib/util/getgrouplist.c
|
lib/util/getgrouplist.c
|
||||||
|
lib/util/gethostname.c
|
||||||
lib/util/getline.c
|
lib/util/getline.c
|
||||||
lib/util/getopt_long.c
|
lib/util/getopt_long.c
|
||||||
lib/util/gidlist.c
|
lib/util/gidlist.c
|
||||||
|
@@ -97,10 +97,6 @@
|
|||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_GETRESUID
|
#undef HAVE_DECL_GETRESUID
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `HOST_NAME_MAX', and to 0 if you
|
|
||||||
don't. */
|
|
||||||
#undef HAVE_DECL_HOST_NAME_MAX
|
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `h_errno', and to 0 if you
|
/* Define to 1 if you have the declaration of `h_errno', and to 0 if you
|
||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_H_ERRNO
|
#undef HAVE_DECL_H_ERRNO
|
||||||
@@ -173,10 +169,6 @@
|
|||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL__INNETGR
|
#undef HAVE_DECL__INNETGR
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `_POSIX_HOST_NAME_MAX', and to 0
|
|
||||||
if you don't. */
|
|
||||||
#undef HAVE_DECL__POSIX_HOST_NAME_MAX
|
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `_POSIX_PATH_MAX', and to 0 if
|
/* Define to 1 if you have the declaration of `_POSIX_PATH_MAX', and to 0 if
|
||||||
you don't. */
|
you don't. */
|
||||||
#undef HAVE_DECL__POSIX_PATH_MAX
|
#undef HAVE_DECL__POSIX_PATH_MAX
|
||||||
|
31
configure
vendored
31
configure
vendored
@@ -21337,20 +21337,6 @@ fi
|
|||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define HAVE_DECL_PATH_MAX $ac_have_decl
|
#define HAVE_DECL_PATH_MAX $ac_have_decl
|
||||||
_ACEOF
|
_ACEOF
|
||||||
ac_fn_c_check_decl "$LINENO" "HOST_NAME_MAX" "ac_cv_have_decl_HOST_NAME_MAX" "
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
"
|
|
||||||
if test "x$ac_cv_have_decl_HOST_NAME_MAX" = xyes; then :
|
|
||||||
ac_have_decl=1
|
|
||||||
else
|
|
||||||
ac_have_decl=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define HAVE_DECL_HOST_NAME_MAX $ac_have_decl
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
ac_fn_c_check_decl "$LINENO" "SIZE_MAX" "ac_cv_have_decl_SIZE_MAX" "
|
ac_fn_c_check_decl "$LINENO" "SIZE_MAX" "ac_cv_have_decl_SIZE_MAX" "
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -21457,23 +21443,6 @@ cat >>confdefs.h <<_ACEOF
|
|||||||
#define HAVE_DECL__POSIX_PATH_MAX $ac_have_decl
|
#define HAVE_DECL__POSIX_PATH_MAX $ac_have_decl
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
fi
|
|
||||||
if test "$ac_cv_have_decl_HOST_NAME_MAX" != "yes"; then
|
|
||||||
ac_fn_c_check_decl "$LINENO" "_POSIX_HOST_NAME_MAX" "ac_cv_have_decl__POSIX_HOST_NAME_MAX" "
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
"
|
|
||||||
if test "x$ac_cv_have_decl__POSIX_HOST_NAME_MAX" = xyes; then :
|
|
||||||
ac_have_decl=1
|
|
||||||
else
|
|
||||||
ac_have_decl=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
|
||||||
#define HAVE_DECL__POSIX_HOST_NAME_MAX $ac_have_decl
|
|
||||||
_ACEOF
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for ac_func in strsignal
|
for ac_func in strsignal
|
||||||
|
@@ -3010,7 +3010,7 @@ dnl We need to add OSDEFS to CFLAGS to expose LLONG_MAX et al on glibc.
|
|||||||
dnl
|
dnl
|
||||||
_CFLAGS="$CFLAGS"
|
_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="$CFLAGS $OSDEFS"
|
CFLAGS="$CFLAGS $OSDEFS"
|
||||||
AC_CHECK_DECLS([LLONG_MAX, LLONG_MIN, ULLONG_MAX, PATH_MAX, HOST_NAME_MAX], [], [], [
|
AC_CHECK_DECLS([LLONG_MAX, LLONG_MIN, ULLONG_MAX, PATH_MAX], [], [], [
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
])
|
])
|
||||||
@@ -3057,12 +3057,6 @@ if test "$ac_cv_have_decl_PATH_MAX" != "yes"; then
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
]])
|
]])
|
||||||
fi
|
fi
|
||||||
if test "$ac_cv_have_decl_HOST_NAME_MAX" != "yes"; then
|
|
||||||
AC_CHECK_DECLS([_POSIX_HOST_NAME_MAX], [], [], [[
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <limits.h>
|
|
||||||
]])
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Check for strsignal() or sys_siglist
|
dnl Check for strsignal() or sys_siglist
|
||||||
|
@@ -160,14 +160,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DECL_HOST_NAME_MAX) && !HAVE_DECL_HOST_NAME_MAX
|
|
||||||
# if defined(HAVE_DECL__POSIX_HOST_NAME_MAX) && HAVE_DECL__POSIX_HOST_NAME_MAX
|
|
||||||
# define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
|
|
||||||
# else
|
|
||||||
# define HOST_NAME_MAX 255
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Posix versions for those without...
|
* Posix versions for those without...
|
||||||
*/
|
*/
|
||||||
|
@@ -144,6 +144,10 @@ __dso_public int aix_restoreauthdb_v1(void);
|
|||||||
__dso_public int aix_setauthdb_v1(char *user);
|
__dso_public int aix_setauthdb_v1(char *user);
|
||||||
#define aix_setauthdb(_a) aix_setauthdb_v1((_a))
|
#define aix_setauthdb(_a) aix_setauthdb_v1((_a))
|
||||||
|
|
||||||
|
/* gethostname.c */
|
||||||
|
__dso_public char *sudo_gethostname_v1(void);
|
||||||
|
#define sudo_gethostname() sudo_gethostname_v1()
|
||||||
|
|
||||||
/* gidlist.c */
|
/* gidlist.c */
|
||||||
__dso_public int sudo_parse_gids_v1(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp);
|
__dso_public int sudo_parse_gids_v1(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp);
|
||||||
#define sudo_parse_gids(_a, _b, _c) sudo_parse_gids_v1((_a), (_b), (_c))
|
#define sudo_parse_gids(_a, _b, _c) sudo_parse_gids_v1((_a), (_b), (_c))
|
||||||
|
@@ -96,8 +96,8 @@ DEVEL = @DEVEL@
|
|||||||
|
|
||||||
SHELL = @SHELL@
|
SHELL = @SHELL@
|
||||||
|
|
||||||
LTOBJS = alloc.lo event.lo fatal.lo key_val.lo gidlist.lo lbuf.lo \
|
LTOBJS = alloc.lo event.lo fatal.lo key_val.lo gethostname.lo gidlist.lo \
|
||||||
locking.lo parseln.lo progname.lo secure_path.lo setgroups.lo \
|
lbuf.lo locking.lo parseln.lo progname.lo secure_path.lo setgroups.lo \
|
||||||
strtobool.lo strtoid.lo strtomode.lo sudo_conf.lo sudo_debug.lo \
|
strtobool.lo strtoid.lo strtomode.lo sudo_conf.lo sudo_debug.lo \
|
||||||
sudo_dso.lo term.lo ttysize.lo @COMMON_OBJS@ @LTLIBOBJS@
|
sudo_dso.lo term.lo ttysize.lo @COMMON_OBJS@ @LTLIBOBJS@
|
||||||
|
|
||||||
@@ -361,6 +361,10 @@ getgrouplist.lo: $(srcdir)/getgrouplist.c $(incdir)/compat/nss_dbdefs.h \
|
|||||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/getgrouplist.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/getgrouplist.c
|
||||||
|
gethostname.lo: $(srcdir)/gethostname.c $(incdir)/compat/stdbool.h \
|
||||||
|
$(incdir)/sudo_compat.h $(incdir)/sudo_util.h \
|
||||||
|
$(top_builddir)/config.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/gethostname.c
|
||||||
getline.lo: $(srcdir)/getline.c $(incdir)/sudo_compat.h $(top_builddir)/config.h
|
getline.lo: $(srcdir)/getline.c $(incdir)/sudo_compat.h $(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/getline.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/getline.c
|
||||||
getopt_long.lo: $(srcdir)/getopt_long.c $(incdir)/compat/getopt.h \
|
getopt_long.lo: $(srcdir)/getopt_long.c $(incdir)/compat/getopt.h \
|
||||||
|
64
lib/util/gethostname.c
Normal file
64
lib/util/gethostname.c
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stddef.h>
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
# endif
|
||||||
|
#endif /* STDC_HEADERS */
|
||||||
|
#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
|
||||||
|
# include <malloc.h>
|
||||||
|
#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "sudo_compat.h"
|
||||||
|
#include "sudo_util.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a malloc()ed copy of the system hostname, or NULL if
|
||||||
|
* malloc() or gethostname() fails.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
sudo_gethostname_v1(void)
|
||||||
|
{
|
||||||
|
char *hname;
|
||||||
|
size_t host_name_max;
|
||||||
|
|
||||||
|
#ifdef _SC_HOST_NAME_MAX
|
||||||
|
host_name_max = (size_t)sysconf(_SC_HOST_NAME_MAX);
|
||||||
|
if (host_name_max == (size_t)-1)
|
||||||
|
#endif
|
||||||
|
host_name_max = 255; /* POSIX and historic BSD */
|
||||||
|
|
||||||
|
hname = malloc(host_name_max + 1);
|
||||||
|
if (hname != NULL) {
|
||||||
|
if (gethostname(hname, host_name_max + 1) == 0) {
|
||||||
|
/* Old gethostname() may not NUL-terminate if there is no room. */
|
||||||
|
hname[host_name_max] = '\0';
|
||||||
|
} else {
|
||||||
|
free(hname);
|
||||||
|
hname = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hname;
|
||||||
|
}
|
@@ -65,6 +65,7 @@ sudo_fatal_callback_register_v1
|
|||||||
sudo_fatal_nodebug_v1
|
sudo_fatal_nodebug_v1
|
||||||
sudo_fatalx_nodebug_v1
|
sudo_fatalx_nodebug_v1
|
||||||
sudo_get_ttysize_v1
|
sudo_get_ttysize_v1
|
||||||
|
sudo_gethostname_v1
|
||||||
sudo_lbuf_append_quoted_v1
|
sudo_lbuf_append_quoted_v1
|
||||||
sudo_lbuf_append_v1
|
sudo_lbuf_append_v1
|
||||||
sudo_lbuf_destroy_v1
|
sudo_lbuf_destroy_v1
|
||||||
|
@@ -911,40 +911,57 @@ done:
|
|||||||
/*
|
/*
|
||||||
* Get NIS-style domain name and copy from static storage or NULL if none.
|
* Get NIS-style domain name and copy from static storage or NULL if none.
|
||||||
*/
|
*/
|
||||||
|
#if defined(HAVE_GETDOMAINNAME) || defined(SI_SRPC_DOMAIN)
|
||||||
const char *
|
const char *
|
||||||
sudo_getdomainname(void)
|
sudo_getdomainname(void)
|
||||||
{
|
{
|
||||||
char *domain = NULL;
|
static char *domain;
|
||||||
#if defined(HAVE_GETDOMAINNAME) || defined(SI_SRPC_DOMAIN)
|
|
||||||
static char buf[HOST_NAME_MAX + 1];
|
|
||||||
static bool initialized;
|
static bool initialized;
|
||||||
|
debug_decl(sudo_getdomainname, SUDOERS_DEBUG_MATCH)
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
size_t host_name_max;
|
||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
# ifdef SI_SRPC_DOMAIN
|
# ifdef _SC_HOST_NAME_MAX
|
||||||
buf[0] = '\0';
|
host_name_max = (size_t)sysconf(_SC_HOST_NAME_MAX);
|
||||||
rval = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf));
|
if (host_name_max == (size_t)-1)
|
||||||
# else
|
|
||||||
rval = getdomainname(buf, sizeof(buf));
|
|
||||||
# endif
|
# endif
|
||||||
if (rval != -1 && buf[0] != '\0') {
|
host_name_max = 255; /* POSIX and historic BSD */
|
||||||
char *cp;
|
|
||||||
|
|
||||||
domain = buf;
|
domain = malloc(host_name_max + 1);
|
||||||
for (cp = buf; *cp != '\0'; cp++) {
|
if (domain != NULL) {
|
||||||
/* Check for illegal characters, Linux may use "(none)". */
|
# ifdef SI_SRPC_DOMAIN
|
||||||
if (*cp == '(' || *cp == ')' || *cp == ',' || *cp == ' ') {
|
domain[0] = '\0';
|
||||||
domain = NULL;
|
rval = sysinfo(SI_SRPC_DOMAIN, domain, host_name_max + 1);
|
||||||
break;
|
# else
|
||||||
|
rval = getdomainname(domain, host_name_max + 1);
|
||||||
|
# endif
|
||||||
|
if (rval != -1 && domain[0] != '\0') {
|
||||||
|
const char *cp;
|
||||||
|
|
||||||
|
for (cp = domain; *cp != '\0'; cp++) {
|
||||||
|
/* Check for illegal characters, Linux may use "(none)". */
|
||||||
|
if (*cp == '(' || *cp == ')' || *cp == ',' || *cp == ' ') {
|
||||||
|
sudo_efree(domain);
|
||||||
|
domain = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_GETDOMAINNAME || SI_SRPC_DOMAIN */
|
debug_return_str(domain);
|
||||||
return domain;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const char *
|
||||||
|
sudo_getdomainname(void)
|
||||||
|
{
|
||||||
|
debug_decl(sudo_getdomainname, SUDOERS_DEBUG_MATCH)
|
||||||
|
debug_return_ptr(NULL);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GETDOMAINNAME || SI_SRPC_DOMAIN */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if "host" and "user" belong to the netgroup "netgr",
|
* Returns true if "host" and "user" belong to the netgroup "netgr",
|
||||||
|
@@ -119,7 +119,6 @@ main(int argc, char *argv[])
|
|||||||
struct privilege *priv;
|
struct privilege *priv;
|
||||||
struct userspec *us;
|
struct userspec *us;
|
||||||
char *p, *grfile, *pwfile;
|
char *p, *grfile, *pwfile;
|
||||||
char hbuf[HOST_NAME_MAX + 1];
|
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
int match, host_match, runas_match, cmnd_match;
|
int match, host_match, runas_match, cmnd_match;
|
||||||
int ch, dflag, exitcode = 0;
|
int ch, dflag, exitcode = 0;
|
||||||
@@ -212,10 +211,8 @@ main(int argc, char *argv[])
|
|||||||
sudo_fatalx(U_("unknown user: %s"), user_name);
|
sudo_fatalx(U_("unknown user: %s"), user_name);
|
||||||
|
|
||||||
if (user_host == NULL) {
|
if (user_host == NULL) {
|
||||||
if (gethostname(hbuf, sizeof(hbuf)) != 0)
|
if ((user_host = sudo_gethostname()) == NULL)
|
||||||
sudo_fatal("gethostname");
|
sudo_fatal("gethostname");
|
||||||
hbuf[sizeof(hbuf) - 1] = '\0';
|
|
||||||
user_host = hbuf;
|
|
||||||
}
|
}
|
||||||
if ((p = strchr(user_host, '.'))) {
|
if ((p = strchr(user_host, '.'))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
@@ -1062,13 +1062,10 @@ get_args(char *cmnd)
|
|||||||
static void
|
static void
|
||||||
get_hostname(void)
|
get_hostname(void)
|
||||||
{
|
{
|
||||||
char *p, thost[HOST_NAME_MAX + 1];
|
char *p;
|
||||||
debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
|
debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
|
||||||
|
|
||||||
if (gethostname(thost, sizeof(thost)) != -1) {
|
if ((user_host = sudo_gethostname()) != NULL) {
|
||||||
thost[sizeof(thost) - 1] = '\0';
|
|
||||||
user_host = sudo_estrdup(thost);
|
|
||||||
|
|
||||||
if ((p = strchr(user_host, '.'))) {
|
if ((p = strchr(user_host, '.'))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
user_shost = sudo_estrdup(user_host);
|
user_shost = sudo_estrdup(user_host);
|
||||||
|
10
src/sudo.c
10
src/sudo.c
@@ -447,7 +447,7 @@ get_user_groups(struct user_details *ud)
|
|||||||
static char **
|
static char **
|
||||||
get_user_info(struct user_details *ud)
|
get_user_info(struct user_details *ud)
|
||||||
{
|
{
|
||||||
char *cp, **user_info, cwd[PATH_MAX], host[HOST_NAME_MAX + 1];
|
char *cp, **user_info, cwd[PATH_MAX];
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int fd, i = 0;
|
int fd, i = 0;
|
||||||
debug_decl(get_user_info, SUDO_DEBUG_UTIL)
|
debug_decl(get_user_info, SUDO_DEBUG_UTIL)
|
||||||
@@ -515,14 +515,12 @@ get_user_info(struct user_details *ud)
|
|||||||
sudo_efree(cp);
|
sudo_efree(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gethostname(host, sizeof(host)) == 0)
|
cp = sudo_gethostname();
|
||||||
host[sizeof(host) - 1] = '\0';
|
user_info[++i] = sudo_new_key_val("host", cp ? cp : "localhost");
|
||||||
else
|
|
||||||
strlcpy(host, "localhost", sizeof(host));
|
|
||||||
user_info[++i] = sudo_new_key_val("host", host);
|
|
||||||
if (user_info[i] == NULL)
|
if (user_info[i] == NULL)
|
||||||
sudo_fatal(NULL);
|
sudo_fatal(NULL);
|
||||||
ud->host = user_info[i] + sizeof("host=") - 1;
|
ud->host = user_info[i] + sizeof("host=") - 1;
|
||||||
|
sudo_efree(cp);
|
||||||
|
|
||||||
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
|
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
|
||||||
sudo_easprintf(&user_info[++i], "lines=%d", ud->ts_lines);
|
sudo_easprintf(&user_info[++i], "lines=%d", ud->ts_lines);
|
||||||
|
Reference in New Issue
Block a user