diff options
author | Karel Zak | 2016-03-07 14:37:31 +0100 |
---|---|---|
committer | Karel Zak | 2016-03-07 14:37:31 +0100 |
commit | bcceb0c7dd61fb876b34e668a6887b92bcce8fca (patch) | |
tree | ae90976b9e627d7c01714e2c7f2697cd30caad05 | |
parent | setarch: fix personality syscall return code check (diff) | |
parent | lib: include strutils.h for mempcpy() (diff) | |
download | kernel-qcow2-util-linux-bcceb0c7dd61fb876b34e668a6887b92bcce8fca.tar.gz kernel-qcow2-util-linux-bcceb0c7dd61fb876b34e668a6887b92bcce8fca.tar.xz kernel-qcow2-util-linux-bcceb0c7dd61fb876b34e668a6887b92bcce8fca.zip |
Merge branch 'port-osx' of https://github.com/rudimeier/util-linux
* 'port-osx' of https://github.com/rudimeier/util-linux:
lib: include strutils.h for mempcpy()
build-sys: remove duplicate cal sources
lib: provide fallback if mkostemp(3) missing
build-sys: chrt requires a sched_set* function
build-sys: add --disable-ipcrm --disable-ipcs
build-sys: disable login-utils if shadow.h or utmp.h is missing
login-utils: minor utmp cleanup
build-sys: build_init should check for flock
newgrp: rename memset_s()
misc: fix some includes
libsmartcols: fix uninitialized variable
fdisk: fix warning, incompatible pointer types passing 'uint64_t *'
logger: use SCM_CREDENTIALS on LINUX only
-rw-r--r-- | configure.ac | 48 | ||||
-rw-r--r-- | disk-utils/fdisk.c | 4 | ||||
-rw-r--r-- | include/fileutils.h | 2 | ||||
-rw-r--r-- | lib/blkdev.c | 3 | ||||
-rw-r--r-- | lib/fileutils.c | 31 | ||||
-rw-r--r-- | lib/mbsalign.c | 1 | ||||
-rw-r--r-- | libblkid/src/save.c | 3 | ||||
-rw-r--r-- | libfdisk/src/gpt.c | 3 | ||||
-rw-r--r-- | libsmartcols/src/table_print.c | 2 | ||||
-rw-r--r-- | login-utils/last.c | 2 | ||||
-rw-r--r-- | login-utils/login.c | 1 | ||||
-rw-r--r-- | login-utils/newgrp.c | 4 | ||||
-rw-r--r-- | misc-utils/Makemodule.am | 10 | ||||
-rw-r--r-- | misc-utils/logger.c | 5 | ||||
-rw-r--r-- | misc-utils/test_uuidd.c | 1 | ||||
-rw-r--r-- | sys-utils/ipcs.c | 1 | ||||
-rw-r--r-- | sys-utils/lsipc.c | 1 | ||||
-rw-r--r-- | sys-utils/rtcwake.c | 1 | ||||
-rw-r--r-- | text-utils/pg.c | 1 |
19 files changed, 89 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac index 7b6a9e725..0c5537faa 100644 --- a/configure.ac +++ b/configure.ac @@ -242,7 +242,6 @@ AC_CHECK_HEADERS([ \ sys/mount.h \ sys/param.h \ sys/prctl.h \ - sys/queue.h \ sys/resource.h \ sys/socket.h \ sys/sockio.h \ @@ -257,6 +256,8 @@ AC_CHECK_HEADERS([ \ sys/ucred.h \ sys/un.h \ unistd.h \ + shadow.h \ + utmp.h \ ]) AC_CHECK_HEADERS([security/pam_misc.h], @@ -286,6 +287,8 @@ have_linux_watchdog_h=$ac_cv_header_linux_watchdog_h have_security_pam_appl_h=$ac_cv_header_security_pam_appl_h have_security_pam_misc_h=$ac_cv_header_security_pam_misc_h have_security_openpam_h=$ac_cv_header_security_openpam_h +have_shadow_h=$ac_cv_header_shadow_h +have_utmp_h=$ac_cv_header_utmp_h AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> @@ -365,6 +368,7 @@ AC_CHECK_FUNCS([ \ llseek \ lseek64 \ mempcpy \ + mkostemp \ nanosleep \ ntp_gettime \ personality \ @@ -376,6 +380,7 @@ AC_CHECK_FUNCS([ \ setresgid \ setresuid \ sched_setattr \ + sched_setscheduler \ sigqueue \ srandom \ strnchr \ @@ -1203,9 +1208,10 @@ AM_CONDITIONAL([BUILD_EJECT], [test "x$build_eject" = xyes]) AC_ARG_ENABLE([agetty], AS_HELP_STRING([--disable-agetty], [do not build agetty]), - [], [UL_DEFAULT_ENABLE([agetty], [yes])] + [], [UL_DEFAULT_ENABLE([agetty], [check])] ) UL_BUILD_INIT([agetty]) +UL_REQUIRES_HAVE([agetty], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_AGETTY], [test "x$build_agetty" = xyes]) AS_IF([test "x$have_futimens" = xyes -a "x$have_inotify_init1" = xyes ], [ AC_DEFINE([AGETTY_RELOAD], [1], [Enable agetty --reload feature]) @@ -1306,6 +1312,8 @@ AM_CONDITIONAL([BUILD_LSCPU], [test "x$build_lscpu" = xyes]) UL_BUILD_INIT([lslogins], [check]) UL_REQUIRES_BUILD([lslogins], [libsmartcols]) +UL_REQUIRES_HAVE([lslogins], [shadow_h], [shadow.h header]) +UL_REQUIRES_HAVE([lslogins], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_LSLOGINS], [test "x$build_lslogins" = xyes]) @@ -1407,17 +1415,25 @@ UL_REQUIRES_SYSCALL_CHECK([pivot_root], [UL_CHECK_SYSCALL([pivot_root])]) AM_CONDITIONAL([BUILD_PIVOT_ROOT], [test "x$build_pivot_root" = xyes]) -UL_BUILD_INIT([flock], [yes]) +UL_BUILD_INIT([flock], [check]) UL_REQUIRES_HAVE([flock], [timer], [timer_create function]) AM_CONDITIONAL([BUILD_FLOCK], [test "x$build_flock" = xyes]) UL_BUILD_INIT([ipcmk], [yes]) AM_CONDITIONAL([BUILD_IPCMK], [test "x$build_ipcmk" = xyes]) -UL_BUILD_INIT([ipcrm], [yes]) +AC_ARG_ENABLE([ipcrm], + AS_HELP_STRING([--disable-ipcrm], [do not build ipcrm]), + [], [UL_DEFAULT_ENABLE([ipcrm], [yes])] +) +UL_BUILD_INIT([ipcrm]) AM_CONDITIONAL([BUILD_IPCRM], [test "x$build_ipcrm" = xyes]) -UL_BUILD_INIT([ipcs], [yes]) +AC_ARG_ENABLE([ipcs], + AS_HELP_STRING([--disable-ipcs], [do not build ipcs]), + [], [UL_DEFAULT_ENABLE([ipcs], [yes])] +) +UL_BUILD_INIT([ipcs]) AM_CONDITIONAL([BUILD_IPCS], [test "x$build_ipcs" = xyes]) UL_BUILD_INIT([lsipc], [check]) @@ -1525,14 +1541,16 @@ AC_ARG_ENABLE([last], [], [UL_DEFAULT_ENABLE([last], [check])] ) UL_BUILD_INIT([last]) +UL_REQUIRES_HAVE([last], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_LAST], [test "x$build_last" = xyes]) AC_ARG_ENABLE([utmpdump], AS_HELP_STRING([--disable-utmpdump], [do not build utmpdump]), - [], [UL_DEFAULT_ENABLE([utmpdump], [yes])] + [], [UL_DEFAULT_ENABLE([utmpdump], [check])] ) UL_BUILD_INIT([utmpdump]) +UL_REQUIRES_HAVE([utmpdump], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_UTMPDUMP], [test "x$build_utmpdump" = xyes]) @@ -1583,6 +1601,7 @@ AC_ARG_ENABLE([vipw], [], [UL_DEFAULT_ENABLE([vipw], [no])] ) UL_BUILD_INIT([vipw]) +UL_REQUIRES_HAVE([vipw], [shadow_h], [shadow.h header]) AM_CONDITIONAL([BUILD_VIPW], [test "x$build_vipw" = xyes]) @@ -1624,6 +1643,7 @@ AC_ARG_ENABLE([chfn-chsh], [], [UL_DEFAULT_ENABLE([chfn_chsh], [check])] ) UL_BUILD_INIT([chfn_chsh]) +UL_REQUIRES_HAVE([chfn_chsh], [shadow_h], [shadow.h header]) AS_IF([test "x$enable_chfn_chsh_password" = xyes -o "x$have_user" = xyes], [ UL_REQUIRES_HAVE([chfn_chsh], [security_pam_appl_h], [PAM header file]) @@ -1649,6 +1669,7 @@ AC_ARG_ENABLE([login], UL_BUILD_INIT([login]) UL_REQUIRES_HAVE([login], [security_pam_appl_h], [PAM header file]) UL_REQUIRES_HAVE([login], [security_pam_misc_h, security_openpam_h], [PAM conversation functions]) +UL_REQUIRES_HAVE([login], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_LOGIN], [test "x$build_login" = xyes]) AC_ARG_ENABLE([login-chown-vcs], @@ -1680,9 +1701,10 @@ AM_CONDITIONAL([BUILD_NOLOGIN], [test "x$build_nologin" = xyes]) AC_ARG_ENABLE([sulogin], AS_HELP_STRING([--disable-sulogin], [do not build sulogin]), - [], [UL_DEFAULT_ENABLE([sulogin], [yes])] + [], [UL_DEFAULT_ENABLE([sulogin], [check])] ) UL_BUILD_INIT([sulogin]) +UL_REQUIRES_HAVE([sulogin], [shadow_h], [shadow.h header]) AM_CONDITIONAL([BUILD_SULOGIN], [test "x$build_sulogin" = xyes]) @@ -1692,6 +1714,7 @@ AC_ARG_ENABLE([su], ) UL_BUILD_INIT([su]) UL_REQUIRES_HAVE([su], [security_pam_appl_h], [PAM header file]) +UL_REQUIRES_HAVE([su], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_SU], [test "x$build_su" = xyes]) @@ -1701,6 +1724,7 @@ AC_ARG_ENABLE([runuser], ) UL_BUILD_INIT([runuser]) UL_REQUIRES_HAVE([runuser], [security_pam_appl_h], [PAM header file]) +UL_REQUIRES_HAVE([runuser], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_RUNUSER], [test "x$build_runuser" = xyes]) @@ -1784,8 +1808,14 @@ UL_REQUIRES_SYSCALL_CHECK([taskset], [sched_getaffinity]) AM_CONDITIONAL([BUILD_TASKSET], [test "x$build_taskset" = xyes]) + +have_schedsetter=no +AS_IF([test "x$ac_cv_func_sched_setscheduler" = xyes], [have_schedsetter=yes], + [test "x$ac_cv_func_sched_setattr" = xyes], [have_schedsetter=yes]) + UL_BUILD_INIT([chrt], [check]) UL_REQUIRES_BUILD([chrt], [schedutils]) +UL_REQUIRES_HAVE([chrt], [schedsetter], [sched_set functions]) AM_CONDITIONAL([BUILD_CHRT], [test "x$build_chrt" = xyes]) AS_IF([test "x$build_chrt" = xyes], [ @@ -1795,9 +1825,10 @@ AS_IF([test "x$build_chrt" = xyes], [ AC_ARG_ENABLE([wall], AS_HELP_STRING([--disable-wall], [do not build wall]), - [], [UL_DEFAULT_ENABLE([wall], [yes])] + [], [UL_DEFAULT_ENABLE([wall], [check])] ) UL_BUILD_INIT([wall]) +UL_REQUIRES_HAVE([wall], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_WALL], [test "x$build_wall" = xyes]) @@ -1806,6 +1837,7 @@ AC_ARG_ENABLE([write], [], [UL_DEFAULT_ENABLE([write], [no])] ) UL_BUILD_INIT([write]) +UL_REQUIRES_HAVE([write], [utmp_h], [utmp.h header]) AM_CONDITIONAL([BUILD_WRITE], [test "x$build_write" = xyes]) diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 0b229839e..2f95fe84a 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -276,7 +276,7 @@ static int ask_offset(struct fdisk_context *cxt, snprintf(prompt, sizeof(prompt), _("%s (%ju-%ju): "), q, low, high); do { - uint64_t num = 0; + uintmax_t num = 0; char sig = 0, *p; int pwr = 0; @@ -313,7 +313,7 @@ static int ask_offset(struct fdisk_context *cxt, if (num >= low && num <= high) { if (sig && pwr) fdisk_ask_number_set_relative(ask, 1); - return fdisk_ask_number_set_result(ask, num); + return fdisk_ask_number_set_result(ask, (uint64_t)num); } fdisk_warnx(cxt, _("Value out of range.")); } while (1); diff --git a/include/fileutils.h b/include/fileutils.h index ba8da7fe6..79dd01237 100644 --- a/include/fileutils.h +++ b/include/fileutils.h @@ -8,6 +8,8 @@ #include "c.h" +extern int mkstemp_cloexec(char *template); + extern int xmkstemp(char **tmpname, const char *dir, const char *prefix); static inline FILE *xfmkstemp(char **tmpname, const char *dir, const char *prefix) diff --git a/lib/blkdev.c b/lib/blkdev.c index 403e9e48a..8a5a52dfa 100644 --- a/lib/blkdev.c +++ b/lib/blkdev.c @@ -19,9 +19,6 @@ #endif #ifdef HAVE_SYS_DISK_H -# ifdef HAVE_SYS_QUEUE_H -# include <sys/queue.h> /* for LIST_HEAD */ -# endif # include <sys/disk.h> #endif diff --git a/lib/fileutils.c b/lib/fileutils.c index bf8e60a4b..15cc92583 100644 --- a/lib/fileutils.c +++ b/lib/fileutils.c @@ -13,6 +13,35 @@ #include "fileutils.h" #include "pathnames.h" +int mkstemp_cloexec(char *template) +{ +#ifdef HAVE_MKOSTEMP + return mkostemp(template, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC); +#else + int fd, old_flags, errno_save; + + fd = mkstemp(template); + if (fd < 0) + return fd; + + old_flags = fcntl(fd, F_GETFD, 0); + if (old_flags < 0) + goto unwind; + if (fcntl(fd, F_SETFD, old_flags | O_CLOEXEC) < 0) + goto unwind; + + return fd; + +unwind: + errno_save = errno; + unlink(template); + close(fd); + errno = errno_save; + + return -1; +#endif +} + /* Create open temporary file in safe way. Please notice that the * file permissions are -rw------- by default. */ int xmkstemp(char **tmpname, const char *dir, const char *prefix) @@ -33,7 +62,7 @@ int xmkstemp(char **tmpname, const char *dir, const char *prefix) return -1; old_mode = umask(077); - fd = mkostemp(localtmp, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC); + fd = mkstemp_cloexec(localtmp); umask(old_mode); if (fd == -1) { free(localtmp); diff --git a/lib/mbsalign.c b/lib/mbsalign.c index 2a8de2f59..f9babba11 100644 --- a/lib/mbsalign.c +++ b/lib/mbsalign.c @@ -27,6 +27,7 @@ #include "c.h" #include "mbsalign.h" +#include "strutils.h" #include "widechar.h" #ifdef HAVE_WIDECHAR diff --git a/libblkid/src/save.c b/libblkid/src/save.c index 5e8bbee8f..307053094 100644 --- a/libblkid/src/save.c +++ b/libblkid/src/save.c @@ -23,6 +23,7 @@ #endif #include "closestream.h" +#include "fileutils.h" #include "blkidP.h" @@ -133,7 +134,7 @@ int blkid_flush_cache(blkid_cache cache) tmp = malloc(strlen(filename) + 8); if (tmp) { sprintf(tmp, "%s-XXXXXX", filename); - fd = mkostemp(tmp, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC); + fd = mkstemp_cloexec(tmp); if (fd >= 0) { if (fchmod(fd, 0644) != 0) DBG(SAVE, ul_debug("%s: fchmod failed", filename)); diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index f795b35a2..cd88df0e6 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -2564,7 +2564,8 @@ static int gpt_toggle_partition_flag( unsigned long flag) { struct fdisk_gpt_label *gpt; - uint64_t attrs, tmp; + uint64_t attrs; + uintmax_t tmp; char *bits; const char *name = NULL; int bit = -1, rc; diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c index d1dcb65bd..510386ec8 100644 --- a/libsmartcols/src/table_print.c +++ b/libsmartcols/src/table_print.c @@ -1281,7 +1281,7 @@ static int initialize_printting(struct libscols_table *tb, struct libscols_buffe scols_reset_iter(&itr, SCOLS_ITER_FORWARD); - while (rc == 0 && scols_table_next_column(tb, &itr, &cl) == 0) { + while (scols_table_next_column(tb, &itr, &cl) == 0) { if (scols_column_is_hidden(cl)) continue; extra_bufsz += strlen(scols_cell_get_data(&cl->header)); /* data */ diff --git a/login-utils/last.c b/login-utils/last.c index dbfa8aed1..38b92efc2 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -586,7 +586,7 @@ static int is_phantom(const struct last_control *ctl, struct utmp *ut) if (ut->UL_UT_TIME < ctl->boot_time.tv_sec) return 1; - pw = getpwnam(ut->ut_name); + pw = getpwnam(ut->ut_user); if (!pw) return 1; sprintf(path, "/proc/%u/loginuid", ut->ut_pid); diff --git a/login-utils/login.c b/login-utils/login.c index e1f11eb9e..c5ce1887e 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -55,7 +55,6 @@ # include <linux/major.h> #endif #include <netdb.h> -#include <lastlog.h> #include <security/pam_appl.h> #ifdef HAVE_SECURITY_PAM_MISC_H # include <security/pam_misc.h> diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 141b41bf4..56639d1f0 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -62,7 +62,7 @@ static char *xgetpass(FILE *input, const char *prompt) /* Ensure memory is set to value c without compiler optimization getting * into way that could happen with memset(3). */ -static int memset_s(void *v, size_t sz, const int c) +static int xmemset_s(void *v, size_t sz, const int c) { volatile unsigned char *p = v; @@ -148,7 +148,7 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge) if (pwd && *pwd && (xpwd = xgetpass(stdin, _("Password: ")))) { char *cbuf = crypt(xpwd, pwd); - memset_s(xpwd, strlen(xpwd), 0); + xmemset_s(xpwd, strlen(xpwd), 0); free(xpwd); if (!cbuf) warn(_("crypt failed")); diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am index aa54919bd..120aadf24 100644 --- a/misc-utils/Makemodule.am +++ b/misc-utils/Makemodule.am @@ -1,15 +1,7 @@ if BUILD_CAL usrbin_exec_PROGRAMS += cal dist_man_MANS += misc-utils/cal.1 -cal_SOURCES = \ - misc-utils/cal.c \ - lib/mbsalign.c \ - lib/strutils.c - -if !HAVE_LANGINFO -cal_SOURCES += lib/langinfo.c -endif - +cal_SOURCES = misc-utils/cal.c cal_CFLAGS = $(AM_CFLAGS) $(NCURSES_CFLAGS) cal_LDADD = $(LDADD) libcommon.la libtcolors.la $(NCURSES_LIBS) endif # BUILD_CAL diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 4201e4335..896d1b8c0 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -53,6 +53,7 @@ #include <pwd.h> #include <sys/types.h> #include <signal.h> +#include <sys/uio.h> #include "all-io.h" #include "c.h" @@ -446,12 +447,14 @@ static void write_output(const struct logger_ctl *ctl, const char *const msg) if (!ctl->noact) { struct msghdr message = { 0 }; +#ifdef SCM_CREDENTIALS struct cmsghdr *cmhp; struct ucred *cred; union { struct cmsghdr cmh; char control[CMSG_SPACE(sizeof(struct ucred))]; } cbuf; +#endif /* 4) add extra \n to make sure message is terminated */ if ((ctl->socket_type == TYPE_TCP) && !ctl->octet_count) @@ -460,6 +463,7 @@ static void write_output(const struct logger_ctl *ctl, const char *const msg) message.msg_iov = iov; message.msg_iovlen = iovlen; +#ifdef SCM_CREDENTIALS /* syslog/journald may follow local socket credentials rather * than in the message PID. If we use --id as root than we can * force kernel to accept another valid PID than the real logger(1) @@ -479,6 +483,7 @@ static void write_output(const struct logger_ctl *ctl, const char *const msg) cred->pid = ctl->pid; } +#endif if (sendmsg(ctl->fd, &message, 0) < 0) warn(_("send message failed")); diff --git a/misc-utils/test_uuidd.c b/misc-utils/test_uuidd.c index 1262e359d..78399b91f 100644 --- a/misc-utils/test_uuidd.c +++ b/misc-utils/test_uuidd.c @@ -24,7 +24,6 @@ * make uuidd uuidgen localstatedir=/var */ #include <error.h> -#include <libgen.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 5877c46b1..0ebcc4c62 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -16,7 +16,6 @@ */ #include <errno.h> -#include <features.h> #include <getopt.h> #include "c.h" diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c index 9e34e6b59..938728ada 100644 --- a/sys-utils/lsipc.c +++ b/sys-utils/lsipc.c @@ -25,7 +25,6 @@ */ #include <errno.h> -#include <features.h> #include <getopt.h> #include <sys/time.h> #include <unistd.h> diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 842ea509c..7c748dcc5 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -22,7 +22,6 @@ #include <errno.h> #include <fcntl.h> #include <getopt.h> -#include <libgen.h> #include <linux/rtc.h> #include <stdio.h> #include <stdlib.h> diff --git a/text-utils/pg.c b/text-utils/pg.c index 998010ad2..9ef00f034 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -58,7 +58,6 @@ #include <unistd.h> #include <signal.h> #include <setjmp.h> -#include <libgen.h> #ifdef HAVE_NCURSES_H # include <ncurses.h> |