diff options
Diffstat (limited to 'lib/roken')
102 files changed, 5547 insertions, 6942 deletions
diff --git a/lib/roken/Makefile.am b/lib/roken/Makefile.am index 1a1593949b79..1f530c7aee52 100644 --- a/lib/roken/Makefile.am +++ b/lib/roken/Makefile.am @@ -8,7 +8,7 @@ CLEANFILES = roken.h make-roken.c $(XHEADERS) lib_LTLIBRARIES = libroken.la -libroken_la_LDFLAGS = -version-info 19:0:1 +libroken_la_LDFLAGS = -version-info 20:0:1 libroken_la_CPPFLAGS = -DBUILD_ROKEN_LIB if versionscript @@ -20,16 +20,19 @@ if HAVE_DBHEADER AM_CPPFLAGS += -I$(DBHEADER) endif -noinst_PROGRAMS = snprintf-test resolve-test rkpty test-detach +bin_PROGRAMS = rkvis rkbase32 rkbase64 +noinst_PROGRAMS = snprintf-test resolve-test rkpty test-detach test-auxval rtbl timeval CHECK_LOCAL = snprintf-test resolve-test rkpty make-roken check_PROGRAMS = \ + base32-test \ base64-test \ getaddrinfo-test \ getifaddrs-test \ - getxxyyy-test \ hex-test \ + test-auxval \ + test-getuserinfo \ test-readenv \ resolve-test \ parse_bytes-test \ @@ -37,6 +40,7 @@ check_PROGRAMS = \ parse_time-test \ snprintf-test \ strpftime-test \ + timeval \ tsearch-test TESTS = $(check_PROGRAMS) @@ -52,6 +56,54 @@ parse_reply_test_SOURCES = parse_reply-test.c resolve.c parse_reply_test_CFLAGS = -DTEST_RESOLVE test_readenv_SOURCES = test-readenv.c test-mem.c +test_auxval_SOURCES = test-auxval.c +test_getuserinfo_SOURCES = test-getuserinfo.c +test_getuserinfo_LDADD = libtest.la $(LDADD) + +if have_err_h +err_h = +else +err_h = err.h +endif + +if have_fnmatch_h +fnmatch_h = +else +fnmatch_h = fnmatch.h +endif + +if have_ifaddrs_h +ifaddrs_h = +else +ifaddrs_h = ifaddrs.h +endif + +if have_search_h +search_h = +else +search_h = search.h +endif + +if have_vis_h +vis_h = +else +vis_h = vis.h +endif + +timeval_SOURCES = timeval.c +timeval_CPPFLAGS = -DTEST + +rkvis_SOURCES = vis.c $(vis_h) vis-extras.h +rkvis_CPPFLAGS = -DTEST + +rkbase32_SOURCES = base32.c +rkbase32_CPPFLAGS = -DTEST + +rkbase64_SOURCES = base64.c +rkbase64_CPPFLAGS = -DTEST + +rtbl_SOURCES = rtbl.c +rtbl_CPPFLAGS = -DTEST test_detach_SOURCES = test-detach.c @@ -69,16 +121,15 @@ tsearch_test_SOURCES = tsearch-test.c tsearch_test_LDADD = libtest.la $(LDADD) tsearch_test_CFLAGS = -DTEST_TSEARCH -getxxyyy_test_SOURCES = getxxyyy.c -getxxyyy_test_CFLAGS = -DTEST_GETXXYYY - resolve_test_SOURCES = resolve-test.c libroken_la_SOURCES = \ + base32.c \ base64.c \ bswap.c \ concat.c \ cloexec.c \ + clz.c \ ct.c \ detach.c \ doxygen.c \ @@ -87,21 +138,25 @@ libroken_la_SOURCES = \ eread.c \ esetenv.c \ ewrite.c \ + fseeko.c \ + ftello.c \ getaddrinfo_hostspec.c \ - get_default_username.c \ get_window_size.c \ getarg.c \ + getauxval.c \ + getauxval.h \ getnameinfo_verified.c \ getprogname.c \ - getxxyyy.c \ + getuserinfo.c \ h_errno.c \ hex.c \ hostent_find_fqdn.c \ issuid.c \ - k_getpwnam.c \ - k_getpwuid.c \ + memmem.c \ mini_inetd.c \ mkdir.c \ + mkdtemp.c \ + mkostemp.c \ net_read.c \ net_write.c \ parse_bytes.c \ @@ -114,6 +169,8 @@ libroken_la_SOURCES = \ roken_gethostby.c \ rtbl.c \ rtbl.h \ + secure_getenv.c \ + secure_getenv.h \ setprogname.c \ signal.c \ simple_exec.c \ @@ -125,8 +182,9 @@ libroken_la_SOURCES = \ timeval.c \ tm2time.c \ unvis.c \ - verify.c \ vis.c \ + $(vis_h) \ + vis-extras.h \ warnerr.c \ write_pid.c \ xfree.c \ @@ -134,59 +192,26 @@ libroken_la_SOURCES = \ EXTRA_libroken_la_SOURCES = \ err.hin \ - glob.hin \ fnmatch.hin \ ifaddrs.hin \ search.hin \ vis.hin libroken_la_LIBADD = @LTLIBOBJS@ $(LIB_crypt) $(LIB_pidfile) - -$(LTLIBOBJS) $(libroken_la_OBJECTS): roken.h $(XHEADERS) - -BUILT_SOURCES = roken.h - -if have_err_h -err_h = -else -err_h = err.h -endif - -if have_fnmatch_h -fnmatch_h = -else -fnmatch_h = fnmatch.h -endif - -if have_glob_h -glob_h = -else -glob_h = glob.h +if SUNOS +libroken_la_LIBADD += -lnsl -lsocket endif -if have_ifaddrs_h -ifaddrs_h = -else -ifaddrs_h = ifaddrs.h -endif - -if have_search_h -search_h = -else -search_h = search.h -endif +$(LTLIBOBJS) $(libroken_la_OBJECTS): roken.h $(XHEADERS) -if have_vis_h -vis_h = -else -vis_h = vis.h -endif +BUILT_SOURCES = roken.h $(err_h) $(fnmatch_h) $(ifaddrs_h) $(search_h) $(vis_h) ## these are controlled by configure -XHEADERS = $(err_h) $(fnmatch_h) $(glob_h) $(ifaddrs_h) $(search_h) $(vis_h) -CLEANFILES += err.h fnmatch.h glob.h ifaddrs.h search.h vis.h +XHEADERS = $(err_h) $(fnmatch_h) $(ifaddrs_h) $(search_h) $(vis_h) +CLEANFILES += err.h fnmatch.h ifaddrs.h search.h vis.h dist_include_HEADERS = \ + base32.h \ base64.h \ getarg.h \ hex.h \ @@ -261,6 +286,7 @@ EXTRA_DIST = \ stdint.hin \ syslogc.c \ syslog.hin \ + test-auxval.c \ test-mem.h \ test-mini_inetd.c \ win32_alloc.c \ diff --git a/lib/roken/Makefile.in b/lib/roken/Makefile.in deleted file mode 100644 index ffb92430e37e..000000000000 --- a/lib/roken/Makefile.in +++ /dev/null @@ -1,3101 +0,0 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2021 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# $Id$ - -# $Id$ - -# $Id$ - - - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -@versionscript_TRUE@am__append_1 = $(LDFLAGS_VERSION_SCRIPT)$(srcdir)/version-script.map -@HAVE_DBHEADER_TRUE@am__append_2 = -I$(DBHEADER) -noinst_PROGRAMS = snprintf-test$(EXEEXT) resolve-test$(EXEEXT) \ - rkpty$(EXEEXT) test-detach$(EXEEXT) $(am__EXEEXT_1) -check_PROGRAMS = base64-test$(EXEEXT) getaddrinfo-test$(EXEEXT) \ - getifaddrs-test$(EXEEXT) getxxyyy-test$(EXEEXT) \ - hex-test$(EXEEXT) test-readenv$(EXEEXT) resolve-test$(EXEEXT) \ - parse_bytes-test$(EXEEXT) parse_reply-test$(EXEEXT) \ - parse_time-test$(EXEEXT) snprintf-test$(EXEEXT) \ - strpftime-test$(EXEEXT) tsearch-test$(EXEEXT) -@have_socket_wrapper_TRUE@am__append_3 = socket_wrapper.c socket_wrapper.h -@have_socket_wrapper_TRUE@am__append_4 = socket_wrapper.h - -# Make make-roken deprecated in 1.4 when we know that roken-h-process.pl works -@CROSS_COMPILE_FALSE@am__append_5 = make-roken -@CROSS_COMPILE_FALSE@am__append_6 = make-roken.c -subdir = lib/roken -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/cf/aix.m4 \ - $(top_srcdir)/cf/auth-modules.m4 \ - $(top_srcdir)/cf/broken-glob.m4 \ - $(top_srcdir)/cf/broken-realloc.m4 \ - $(top_srcdir)/cf/broken-snprintf.m4 $(top_srcdir)/cf/broken.m4 \ - $(top_srcdir)/cf/broken2.m4 $(top_srcdir)/cf/c-attribute.m4 \ - $(top_srcdir)/cf/capabilities.m4 \ - $(top_srcdir)/cf/check-compile-et.m4 \ - $(top_srcdir)/cf/check-getpwnam_r-posix.m4 \ - $(top_srcdir)/cf/check-man.m4 \ - $(top_srcdir)/cf/check-netinet-ip-and-tcp.m4 \ - $(top_srcdir)/cf/check-type-extra.m4 \ - $(top_srcdir)/cf/check-var.m4 $(top_srcdir)/cf/crypto.m4 \ - $(top_srcdir)/cf/db.m4 $(top_srcdir)/cf/destdirs.m4 \ - $(top_srcdir)/cf/dispatch.m4 $(top_srcdir)/cf/dlopen.m4 \ - $(top_srcdir)/cf/find-func-no-libs.m4 \ - $(top_srcdir)/cf/find-func-no-libs2.m4 \ - $(top_srcdir)/cf/find-func.m4 \ - $(top_srcdir)/cf/find-if-not-broken.m4 \ - $(top_srcdir)/cf/framework-security.m4 \ - $(top_srcdir)/cf/have-struct-field.m4 \ - $(top_srcdir)/cf/have-type.m4 $(top_srcdir)/cf/irix.m4 \ - $(top_srcdir)/cf/krb-bigendian.m4 \ - $(top_srcdir)/cf/krb-func-getlogin.m4 \ - $(top_srcdir)/cf/krb-ipv6.m4 $(top_srcdir)/cf/krb-prog-ln-s.m4 \ - $(top_srcdir)/cf/krb-prog-perl.m4 \ - $(top_srcdir)/cf/krb-readline.m4 \ - $(top_srcdir)/cf/krb-struct-spwd.m4 \ - $(top_srcdir)/cf/krb-struct-winsize.m4 \ - $(top_srcdir)/cf/largefile.m4 $(top_srcdir)/cf/libtool.m4 \ - $(top_srcdir)/cf/ltoptions.m4 $(top_srcdir)/cf/ltsugar.m4 \ - $(top_srcdir)/cf/ltversion.m4 $(top_srcdir)/cf/lt~obsolete.m4 \ - $(top_srcdir)/cf/mips-abi.m4 $(top_srcdir)/cf/misc.m4 \ - $(top_srcdir)/cf/need-proto.m4 $(top_srcdir)/cf/osfc2.m4 \ - $(top_srcdir)/cf/otp.m4 $(top_srcdir)/cf/pkg.m4 \ - $(top_srcdir)/cf/proto-compat.m4 $(top_srcdir)/cf/pthreads.m4 \ - $(top_srcdir)/cf/resolv.m4 $(top_srcdir)/cf/retsigtype.m4 \ - $(top_srcdir)/cf/roken-frag.m4 \ - $(top_srcdir)/cf/socket-wrapper.m4 $(top_srcdir)/cf/sunos.m4 \ - $(top_srcdir)/cf/telnet.m4 $(top_srcdir)/cf/test-package.m4 \ - $(top_srcdir)/cf/version-script.m4 $(top_srcdir)/cf/wflags.m4 \ - $(top_srcdir)/cf/win32.m4 $(top_srcdir)/cf/with-all.m4 \ - $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__dist_include_HEADERS_DIST) \ - $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -@CROSS_COMPILE_FALSE@am__EXEEXT_1 = make-roken$(EXEEXT) -PROGRAMS = $(noinst_PROGRAMS) -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" \ - "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)" \ - "$(DESTDIR)$(rokenincludedir)" -LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) -am__DEPENDENCIES_1 = -libroken_la_DEPENDENCIES = @LTLIBOBJS@ $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) -am__libroken_la_SOURCES_DIST = base64.c bswap.c concat.c cloexec.c \ - ct.c detach.c doxygen.c dumpdata.c environment.c eread.c \ - esetenv.c ewrite.c getaddrinfo_hostspec.c \ - get_default_username.c get_window_size.c getarg.c \ - getnameinfo_verified.c getprogname.c getxxyyy.c h_errno.c \ - hex.c hostent_find_fqdn.c issuid.c k_getpwnam.c k_getpwuid.c \ - mini_inetd.c mkdir.c net_read.c net_write.c parse_bytes.c \ - parse_time.c parse_units.c qsort.c rand.c realloc.c resolve.c \ - roken_gethostby.c rtbl.c rtbl.h setprogname.c signal.c \ - simple_exec.c snprintf.c socket.c strcollect.c strerror_r.c \ - strpool.c timeval.c tm2time.c unvis.c verify.c vis.c warnerr.c \ - write_pid.c xfree.c xdbm.h socket_wrapper.c socket_wrapper.h -@have_socket_wrapper_TRUE@am__objects_1 = \ -@have_socket_wrapper_TRUE@ libroken_la-socket_wrapper.lo -am_libroken_la_OBJECTS = libroken_la-base64.lo libroken_la-bswap.lo \ - libroken_la-concat.lo libroken_la-cloexec.lo libroken_la-ct.lo \ - libroken_la-detach.lo libroken_la-doxygen.lo \ - libroken_la-dumpdata.lo libroken_la-environment.lo \ - libroken_la-eread.lo libroken_la-esetenv.lo \ - libroken_la-ewrite.lo libroken_la-getaddrinfo_hostspec.lo \ - libroken_la-get_default_username.lo \ - libroken_la-get_window_size.lo libroken_la-getarg.lo \ - libroken_la-getnameinfo_verified.lo libroken_la-getprogname.lo \ - libroken_la-getxxyyy.lo libroken_la-h_errno.lo \ - libroken_la-hex.lo libroken_la-hostent_find_fqdn.lo \ - libroken_la-issuid.lo libroken_la-k_getpwnam.lo \ - libroken_la-k_getpwuid.lo libroken_la-mini_inetd.lo \ - libroken_la-mkdir.lo libroken_la-net_read.lo \ - libroken_la-net_write.lo libroken_la-parse_bytes.lo \ - libroken_la-parse_time.lo libroken_la-parse_units.lo \ - libroken_la-qsort.lo libroken_la-rand.lo \ - libroken_la-realloc.lo libroken_la-resolve.lo \ - libroken_la-roken_gethostby.lo libroken_la-rtbl.lo \ - libroken_la-setprogname.lo libroken_la-signal.lo \ - libroken_la-simple_exec.lo libroken_la-snprintf.lo \ - libroken_la-socket.lo libroken_la-strcollect.lo \ - libroken_la-strerror_r.lo libroken_la-strpool.lo \ - libroken_la-timeval.lo libroken_la-tm2time.lo \ - libroken_la-unvis.lo libroken_la-verify.lo libroken_la-vis.lo \ - libroken_la-warnerr.lo libroken_la-write_pid.lo \ - libroken_la-xfree.lo $(am__objects_1) -libroken_la_OBJECTS = $(am_libroken_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libroken_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libroken_la_LDFLAGS) $(LDFLAGS) -o $@ -libtest_la_LIBADD = -am_libtest_la_OBJECTS = libtest_la-strftime.lo libtest_la-strptime.lo \ - libtest_la-snprintf.lo libtest_la-tsearch.lo -libtest_la_OBJECTS = $(am_libtest_la_OBJECTS) -libtest_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libtest_la_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -base64_test_SOURCES = base64-test.c -base64_test_OBJECTS = base64-test.$(OBJEXT) -base64_test_LDADD = $(LDADD) -base64_test_DEPENDENCIES = libroken.la -getaddrinfo_test_SOURCES = getaddrinfo-test.c -getaddrinfo_test_OBJECTS = getaddrinfo-test.$(OBJEXT) -getaddrinfo_test_LDADD = $(LDADD) -getaddrinfo_test_DEPENDENCIES = libroken.la -getifaddrs_test_SOURCES = getifaddrs-test.c -getifaddrs_test_OBJECTS = getifaddrs-test.$(OBJEXT) -getifaddrs_test_LDADD = $(LDADD) -getifaddrs_test_DEPENDENCIES = libroken.la -am_getxxyyy_test_OBJECTS = getxxyyy_test-getxxyyy.$(OBJEXT) -getxxyyy_test_OBJECTS = $(am_getxxyyy_test_OBJECTS) -getxxyyy_test_LDADD = $(LDADD) -getxxyyy_test_DEPENDENCIES = libroken.la -getxxyyy_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(getxxyyy_test_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -hex_test_SOURCES = hex-test.c -hex_test_OBJECTS = hex-test.$(OBJEXT) -hex_test_LDADD = $(LDADD) -hex_test_DEPENDENCIES = libroken.la -@CROSS_COMPILE_FALSE@nodist_make_roken_OBJECTS = make-roken.$(OBJEXT) -make_roken_OBJECTS = $(nodist_make_roken_OBJECTS) -make_roken_DEPENDENCIES = -parse_bytes_test_SOURCES = parse_bytes-test.c -parse_bytes_test_OBJECTS = parse_bytes-test.$(OBJEXT) -parse_bytes_test_LDADD = $(LDADD) -parse_bytes_test_DEPENDENCIES = libroken.la -am_parse_reply_test_OBJECTS = \ - parse_reply_test-parse_reply-test.$(OBJEXT) \ - parse_reply_test-resolve.$(OBJEXT) -parse_reply_test_OBJECTS = $(am_parse_reply_test_OBJECTS) -parse_reply_test_LDADD = $(LDADD) -parse_reply_test_DEPENDENCIES = libroken.la -parse_reply_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(parse_reply_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -am_parse_time_test_OBJECTS = parse_time-test.$(OBJEXT) \ - test-mem.$(OBJEXT) -parse_time_test_OBJECTS = $(am_parse_time_test_OBJECTS) -parse_time_test_LDADD = $(LDADD) -parse_time_test_DEPENDENCIES = libroken.la -am_resolve_test_OBJECTS = resolve-test.$(OBJEXT) -resolve_test_OBJECTS = $(am_resolve_test_OBJECTS) -resolve_test_LDADD = $(LDADD) -resolve_test_DEPENDENCIES = libroken.la -rkpty_SOURCES = rkpty.c -rkpty_OBJECTS = rkpty.$(OBJEXT) -rkpty_DEPENDENCIES = $(am__DEPENDENCIES_1) $(LDADD) -am_snprintf_test_OBJECTS = snprintf_test-snprintf-test.$(OBJEXT) -snprintf_test_OBJECTS = $(am_snprintf_test_OBJECTS) -snprintf_test_DEPENDENCIES = libtest.la $(LDADD) -snprintf_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(snprintf_test_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -am_strpftime_test_OBJECTS = strpftime_test-strpftime-test.$(OBJEXT) -strpftime_test_OBJECTS = $(am_strpftime_test_OBJECTS) -strpftime_test_DEPENDENCIES = libtest.la $(LDADD) -strpftime_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(strpftime_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \ - $@ -am_test_detach_OBJECTS = test-detach.$(OBJEXT) -test_detach_OBJECTS = $(am_test_detach_OBJECTS) -test_detach_LDADD = $(LDADD) -test_detach_DEPENDENCIES = libroken.la -am_test_readenv_OBJECTS = test-readenv.$(OBJEXT) test-mem.$(OBJEXT) -test_readenv_OBJECTS = $(am_test_readenv_OBJECTS) -test_readenv_LDADD = $(LDADD) -test_readenv_DEPENDENCIES = libroken.la -am_tsearch_test_OBJECTS = tsearch_test-tsearch-test.$(OBJEXT) -tsearch_test_OBJECTS = $(am_tsearch_test_OBJECTS) -tsearch_test_DEPENDENCIES = libtest.la $(LDADD) -tsearch_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(tsearch_test_CFLAGS) \ - $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__maybe_remake_depfiles = depfiles -am__depfiles_remade = $(DEPDIR)/chown.Plo $(DEPDIR)/closefrom.Plo \ - $(DEPDIR)/copyhostent.Plo $(DEPDIR)/daemon.Plo \ - $(DEPDIR)/ecalloc.Plo $(DEPDIR)/emalloc.Plo \ - $(DEPDIR)/erealloc.Plo $(DEPDIR)/err.Plo $(DEPDIR)/errx.Plo \ - $(DEPDIR)/estrdup.Plo $(DEPDIR)/fchown.Plo $(DEPDIR)/flock.Plo \ - $(DEPDIR)/fnmatch.Plo $(DEPDIR)/freeaddrinfo.Plo \ - $(DEPDIR)/freehostent.Plo $(DEPDIR)/gai_strerror.Plo \ - $(DEPDIR)/getaddrinfo.Plo $(DEPDIR)/getcap.Plo \ - $(DEPDIR)/getcwd.Plo $(DEPDIR)/getdtablesize.Plo \ - $(DEPDIR)/getegid.Plo $(DEPDIR)/geteuid.Plo \ - $(DEPDIR)/getgid.Plo $(DEPDIR)/gethostname.Plo \ - $(DEPDIR)/getifaddrs.Plo $(DEPDIR)/getipnodebyaddr.Plo \ - $(DEPDIR)/getipnodebyname.Plo $(DEPDIR)/getnameinfo.Plo \ - $(DEPDIR)/getopt.Plo $(DEPDIR)/gettimeofday.Plo \ - $(DEPDIR)/getuid.Plo $(DEPDIR)/getusershell.Plo \ - $(DEPDIR)/glob.Plo $(DEPDIR)/hstrerror.Plo \ - $(DEPDIR)/inet_aton.Plo $(DEPDIR)/inet_ntop.Plo \ - $(DEPDIR)/inet_pton.Plo $(DEPDIR)/initgroups.Plo \ - $(DEPDIR)/innetgr.Plo $(DEPDIR)/iruserok.Plo \ - $(DEPDIR)/localtime_r.Plo $(DEPDIR)/lstat.Plo \ - $(DEPDIR)/memmove.Plo $(DEPDIR)/memset_s.Plo \ - $(DEPDIR)/mkstemp.Plo $(DEPDIR)/putenv.Plo $(DEPDIR)/rcmd.Plo \ - $(DEPDIR)/readv.Plo $(DEPDIR)/recvmsg.Plo \ - $(DEPDIR)/sendmsg.Plo $(DEPDIR)/setegid.Plo \ - $(DEPDIR)/setenv.Plo $(DEPDIR)/seteuid.Plo \ - $(DEPDIR)/strcasecmp.Plo $(DEPDIR)/strdup.Plo \ - $(DEPDIR)/strerror.Plo $(DEPDIR)/strftime.Plo \ - $(DEPDIR)/strlcat.Plo $(DEPDIR)/strlcpy.Plo \ - $(DEPDIR)/strlwr.Plo $(DEPDIR)/strncasecmp.Plo \ - $(DEPDIR)/strndup.Plo $(DEPDIR)/strnlen.Plo \ - $(DEPDIR)/strptime.Plo $(DEPDIR)/strsep.Plo \ - $(DEPDIR)/strsep_copy.Plo $(DEPDIR)/strtok_r.Plo \ - $(DEPDIR)/strtoll.Plo $(DEPDIR)/strtoull.Plo \ - $(DEPDIR)/strupr.Plo $(DEPDIR)/swab.Plo $(DEPDIR)/timegm.Plo \ - $(DEPDIR)/tsearch.Plo $(DEPDIR)/unsetenv.Plo \ - $(DEPDIR)/verr.Plo $(DEPDIR)/verrx.Plo $(DEPDIR)/vsyslog.Plo \ - $(DEPDIR)/vwarn.Plo $(DEPDIR)/vwarnx.Plo $(DEPDIR)/warn.Plo \ - $(DEPDIR)/warnx.Plo $(DEPDIR)/writev.Plo \ - ./$(DEPDIR)/base64-test.Po ./$(DEPDIR)/getaddrinfo-test.Po \ - ./$(DEPDIR)/getifaddrs-test.Po \ - ./$(DEPDIR)/getxxyyy_test-getxxyyy.Po ./$(DEPDIR)/hex-test.Po \ - ./$(DEPDIR)/libroken_la-base64.Plo \ - ./$(DEPDIR)/libroken_la-bswap.Plo \ - ./$(DEPDIR)/libroken_la-cloexec.Plo \ - ./$(DEPDIR)/libroken_la-concat.Plo \ - ./$(DEPDIR)/libroken_la-ct.Plo \ - ./$(DEPDIR)/libroken_la-detach.Plo \ - ./$(DEPDIR)/libroken_la-doxygen.Plo \ - ./$(DEPDIR)/libroken_la-dumpdata.Plo \ - ./$(DEPDIR)/libroken_la-environment.Plo \ - ./$(DEPDIR)/libroken_la-eread.Plo \ - ./$(DEPDIR)/libroken_la-esetenv.Plo \ - ./$(DEPDIR)/libroken_la-ewrite.Plo \ - ./$(DEPDIR)/libroken_la-get_default_username.Plo \ - ./$(DEPDIR)/libroken_la-get_window_size.Plo \ - ./$(DEPDIR)/libroken_la-getaddrinfo_hostspec.Plo \ - ./$(DEPDIR)/libroken_la-getarg.Plo \ - ./$(DEPDIR)/libroken_la-getnameinfo_verified.Plo \ - ./$(DEPDIR)/libroken_la-getprogname.Plo \ - ./$(DEPDIR)/libroken_la-getxxyyy.Plo \ - ./$(DEPDIR)/libroken_la-h_errno.Plo \ - ./$(DEPDIR)/libroken_la-hex.Plo \ - ./$(DEPDIR)/libroken_la-hostent_find_fqdn.Plo \ - ./$(DEPDIR)/libroken_la-issuid.Plo \ - ./$(DEPDIR)/libroken_la-k_getpwnam.Plo \ - ./$(DEPDIR)/libroken_la-k_getpwuid.Plo \ - ./$(DEPDIR)/libroken_la-mini_inetd.Plo \ - ./$(DEPDIR)/libroken_la-mkdir.Plo \ - ./$(DEPDIR)/libroken_la-net_read.Plo \ - ./$(DEPDIR)/libroken_la-net_write.Plo \ - ./$(DEPDIR)/libroken_la-parse_bytes.Plo \ - ./$(DEPDIR)/libroken_la-parse_time.Plo \ - ./$(DEPDIR)/libroken_la-parse_units.Plo \ - ./$(DEPDIR)/libroken_la-qsort.Plo \ - ./$(DEPDIR)/libroken_la-rand.Plo \ - ./$(DEPDIR)/libroken_la-realloc.Plo \ - ./$(DEPDIR)/libroken_la-resolve.Plo \ - ./$(DEPDIR)/libroken_la-roken_gethostby.Plo \ - ./$(DEPDIR)/libroken_la-rtbl.Plo \ - ./$(DEPDIR)/libroken_la-setprogname.Plo \ - ./$(DEPDIR)/libroken_la-signal.Plo \ - ./$(DEPDIR)/libroken_la-simple_exec.Plo \ - ./$(DEPDIR)/libroken_la-snprintf.Plo \ - ./$(DEPDIR)/libroken_la-socket.Plo \ - ./$(DEPDIR)/libroken_la-socket_wrapper.Plo \ - ./$(DEPDIR)/libroken_la-strcollect.Plo \ - ./$(DEPDIR)/libroken_la-strerror_r.Plo \ - ./$(DEPDIR)/libroken_la-strpool.Plo \ - ./$(DEPDIR)/libroken_la-timeval.Plo \ - ./$(DEPDIR)/libroken_la-tm2time.Plo \ - ./$(DEPDIR)/libroken_la-unvis.Plo \ - ./$(DEPDIR)/libroken_la-verify.Plo \ - ./$(DEPDIR)/libroken_la-vis.Plo \ - ./$(DEPDIR)/libroken_la-warnerr.Plo \ - ./$(DEPDIR)/libroken_la-write_pid.Plo \ - ./$(DEPDIR)/libroken_la-xfree.Plo \ - ./$(DEPDIR)/libtest_la-snprintf.Plo \ - ./$(DEPDIR)/libtest_la-strftime.Plo \ - ./$(DEPDIR)/libtest_la-strptime.Plo \ - ./$(DEPDIR)/libtest_la-tsearch.Plo ./$(DEPDIR)/make-roken.Po \ - ./$(DEPDIR)/parse_bytes-test.Po \ - ./$(DEPDIR)/parse_reply_test-parse_reply-test.Po \ - ./$(DEPDIR)/parse_reply_test-resolve.Po \ - ./$(DEPDIR)/parse_time-test.Po ./$(DEPDIR)/resolve-test.Po \ - ./$(DEPDIR)/rkpty.Po \ - ./$(DEPDIR)/snprintf_test-snprintf-test.Po \ - ./$(DEPDIR)/strpftime_test-strpftime-test.Po \ - ./$(DEPDIR)/test-detach.Po ./$(DEPDIR)/test-mem.Po \ - ./$(DEPDIR)/test-readenv.Po \ - ./$(DEPDIR)/tsearch_test-tsearch-test.Po -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libroken_la_SOURCES) $(EXTRA_libroken_la_SOURCES) \ - $(libtest_la_SOURCES) base64-test.c getaddrinfo-test.c \ - getifaddrs-test.c $(getxxyyy_test_SOURCES) hex-test.c \ - $(nodist_make_roken_SOURCES) parse_bytes-test.c \ - $(parse_reply_test_SOURCES) $(parse_time_test_SOURCES) \ - $(resolve_test_SOURCES) rkpty.c $(snprintf_test_SOURCES) \ - $(strpftime_test_SOURCES) $(test_detach_SOURCES) \ - $(test_readenv_SOURCES) $(tsearch_test_SOURCES) -DIST_SOURCES = $(am__libroken_la_SOURCES_DIST) \ - $(EXTRA_libroken_la_SOURCES) $(libtest_la_SOURCES) \ - base64-test.c getaddrinfo-test.c getifaddrs-test.c \ - $(getxxyyy_test_SOURCES) hex-test.c parse_bytes-test.c \ - $(parse_reply_test_SOURCES) $(parse_time_test_SOURCES) \ - $(resolve_test_SOURCES) rkpty.c $(snprintf_test_SOURCES) \ - $(strpftime_test_SOURCES) $(test_detach_SOURCES) \ - $(test_readenv_SOURCES) $(tsearch_test_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -man3dir = $(mandir)/man3 -MANS = $(man_MANS) -am__dist_include_HEADERS_DIST = base64.h getarg.h hex.h parse_bytes.h \ - parse_time.h parse_units.h resolve.h roken-common.h rtbl.h \ - xdbm.h socket_wrapper.h -HEADERS = $(dist_include_HEADERS) $(nodist_include_HEADERS) \ - $(nodist_rokeninclude_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red='[0;31m'; \ - grn='[0;32m'; \ - lgn='[1;32m'; \ - blu='[1;34m'; \ - mgn='[0;35m'; \ - brg='[1m'; \ - std='[m'; \ - fi; \ -} -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/Makefile.am.common \ - $(top_srcdir)/cf/Makefile.am.common $(top_srcdir)/depcomp \ - $(top_srcdir)/test-driver ChangeLog chown.c closefrom.c \ - copyhostent.c daemon.c ecalloc.c emalloc.c erealloc.c err.c \ - errx.c estrdup.c fchown.c flock.c fnmatch.c freeaddrinfo.c \ - freehostent.c gai_strerror.c getaddrinfo.c getcap.c getcwd.c \ - getdtablesize.c getegid.c geteuid.c getgid.c gethostname.c \ - getifaddrs.c getipnodebyaddr.c getipnodebyname.c getnameinfo.c \ - getopt.c gettimeofday.c getuid.c getusershell.c glob.c \ - hstrerror.c inet_aton.c inet_ntop.c inet_pton.c initgroups.c \ - innetgr.c install-sh iruserok.c localtime_r.c lstat.c \ - memmove.c memset_s.c missing mkinstalldirs mkstemp.c putenv.c \ - rcmd.c readv.c recvmsg.c sendmsg.c setegid.c setenv.c \ - seteuid.c strcasecmp.c strdup.c strerror.c strftime.c \ - strlcat.c strlcpy.c strlwr.c strncasecmp.c strndup.c strnlen.c \ - strptime.c strsep.c strsep_copy.c strtok_r.c strtoll.c \ - strtoull.c strupr.c swab.c timegm.c tsearch.c unsetenv.c \ - verr.c verrx.c vsyslog.c vwarn.c vwarnx.c warn.c warnx.c \ - writev.c -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AS = @AS@ -ASN1_COMPILE = @ASN1_COMPILE@ -ASN1_COMPILE_DEP = @ASN1_COMPILE_DEP@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CANONICAL_HOST = @CANONICAL_HOST@ -CAPNG_CFLAGS = @CAPNG_CFLAGS@ -CAPNG_LIBS = @CAPNG_LIBS@ -CATMAN = @CATMAN@ -CATMANEXT = @CATMANEXT@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CLANG_FORMAT = @CLANG_FORMAT@ -COMPILE_ET = @COMPILE_ET@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CSCOPE = @CSCOPE@ -CTAGS = @CTAGS@ -CYGPATH_W = @CYGPATH_W@ -DB1LIB = @DB1LIB@ -DB3LIB = @DB3LIB@ -DBHEADER = @DBHEADER@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DIR_com_err = @DIR_com_err@ -DIR_hdbdir = @DIR_hdbdir@ -DIR_roken = @DIR_roken@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -ENABLE_AFS_STRING_TO_KEY = @ENABLE_AFS_STRING_TO_KEY@ -ETAGS = @ETAGS@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -FILECMD = @FILECMD@ -GCD_MIG = @GCD_MIG@ -GREP = @GREP@ -GROFF = @GROFF@ -INCLUDES_roken = @INCLUDES_roken@ -INCLUDE_libedit = @INCLUDE_libedit@ -INCLUDE_libintl = @INCLUDE_libintl@ -INCLUDE_openldap = @INCLUDE_openldap@ -INCLUDE_openssl_crypto = @INCLUDE_openssl_crypto@ -INCLUDE_readline = @INCLUDE_readline@ -INCLUDE_sqlite3 = @INCLUDE_sqlite3@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LDFLAGS_VERSION_SCRIPT = @LDFLAGS_VERSION_SCRIPT@ -LEX = @LEX@ -LEXLIB = @LEXLIB@ -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LIBADD_roken = @LIBADD_roken@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@ -LIB_bswap16 = @LIB_bswap16@ -LIB_bswap32 = @LIB_bswap32@ -LIB_bswap64 = @LIB_bswap64@ -LIB_com_err = @LIB_com_err@ -LIB_com_err_a = @LIB_com_err_a@ -LIB_com_err_so = @LIB_com_err_so@ -LIB_crypt = @LIB_crypt@ -LIB_db_create = @LIB_db_create@ -LIB_dbm_firstkey = @LIB_dbm_firstkey@ -LIB_dbopen = @LIB_dbopen@ -LIB_dispatch_async_f = @LIB_dispatch_async_f@ -LIB_dladdr = @LIB_dladdr@ -LIB_dlopen = @LIB_dlopen@ -LIB_dn_expand = @LIB_dn_expand@ -LIB_dns_search = @LIB_dns_search@ -LIB_door_create = @LIB_door_create@ -LIB_freeaddrinfo = @LIB_freeaddrinfo@ -LIB_gai_strerror = @LIB_gai_strerror@ -LIB_getaddrinfo = @LIB_getaddrinfo@ -LIB_gethostbyname = @LIB_gethostbyname@ -LIB_gethostbyname2 = @LIB_gethostbyname2@ -LIB_getnameinfo = @LIB_getnameinfo@ -LIB_getpwnam_r = @LIB_getpwnam_r@ -LIB_getsockopt = @LIB_getsockopt@ -LIB_hcrypto = @LIB_hcrypto@ -LIB_hcrypto_a = @LIB_hcrypto_a@ -LIB_hcrypto_appl = @LIB_hcrypto_appl@ -LIB_hcrypto_so = @LIB_hcrypto_so@ -LIB_hstrerror = @LIB_hstrerror@ -LIB_kdb = @LIB_kdb@ -LIB_libedit = @LIB_libedit@ -LIB_libintl = @LIB_libintl@ -LIB_loadquery = @LIB_loadquery@ -LIB_logout = @LIB_logout@ -LIB_logwtmp = @LIB_logwtmp@ -LIB_openldap = @LIB_openldap@ -LIB_openpty = @LIB_openpty@ -LIB_openssl_crypto = @LIB_openssl_crypto@ -LIB_otp = @LIB_otp@ -LIB_pidfile = @LIB_pidfile@ -LIB_readline = @LIB_readline@ -LIB_res_ndestroy = @LIB_res_ndestroy@ -LIB_res_nsearch = @LIB_res_nsearch@ -LIB_res_search = @LIB_res_search@ -LIB_roken = @LIB_roken@ -LIB_security = @LIB_security@ -LIB_setsockopt = @LIB_setsockopt@ -LIB_socket = @LIB_socket@ -LIB_sqlite3 = @LIB_sqlite3@ -LIB_syslog = @LIB_syslog@ -LIB_tgetent = @LIB_tgetent@ -LIPO = @LIPO@ -LMDBLIB = @LMDBLIB@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NDBMLIB = @NDBMLIB@ -NM = @NM@ -NMEDIT = @NMEDIT@ -NO_AFS = @NO_AFS@ -NROFF = @NROFF@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PERL = @PERL@ -PKG_CONFIG = @PKG_CONFIG@ -PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ -PTHREAD_LDADD = @PTHREAD_LDADD@ -PTHREAD_LIBADD = @PTHREAD_LIBADD@ -PYTHON = @PYTHON@ -PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ -PYTHON_PLATFORM = @PYTHON_PLATFORM@ -PYTHON_PREFIX = @PYTHON_PREFIX@ -PYTHON_VERSION = @PYTHON_VERSION@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SLC = @SLC@ -SLC_DEP = @SLC_DEP@ -STRIP = @STRIP@ -VERSION = @VERSION@ -VERSIONING = @VERSIONING@ -WFLAGS = @WFLAGS@ -WFLAGS_LITE = @WFLAGS_LITE@ -YACC = @YACC@ -YFLAGS = @YFLAGS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -db_type = @db_type@ -db_type_preference = @db_type_preference@ -docdir = @docdir@ -dpagaix_cflags = @dpagaix_cflags@ -dpagaix_ldadd = @dpagaix_ldadd@ -dpagaix_ldflags = @dpagaix_ldflags@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgpyexecdir = @pkgpyexecdir@ -pkgpythondir = @pkgpythondir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -pyexecdir = @pyexecdir@ -pythondir = @pythondir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -subdirs = @subdirs@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUFFIXES = .et .h .pc.in .pc .x .z .hx .1 .3 .5 .7 .8 .cat1 .cat3 \ - .cat5 .cat7 .cat8 .hin -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include -AM_CPPFLAGS = $(INCLUDES_roken) $(libroken_la_CPPFLAGS) \ - $(am__append_2) -@do_roken_rename_TRUE@ROKEN_RENAME = -DROKEN_RENAME -AM_CFLAGS = $(WFLAGS) -CP = cp -buildinclude = $(top_builddir)/include -LIB_XauReadAuth = @LIB_XauReadAuth@ -LIB_el_init = @LIB_el_init@ -LIB_getattr = @LIB_getattr@ -LIB_getpwent_r = @LIB_getpwent_r@ -LIB_odm_initialize = @LIB_odm_initialize@ -LIB_setpcred = @LIB_setpcred@ -INCLUDE_krb4 = @INCLUDE_krb4@ -LIB_krb4 = @LIB_krb4@ -libexec_heimdaldir = $(libexecdir)/heimdal -NROFF_MAN = groff -mandoc -Tascii -@NO_AFS_FALSE@LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) -@NO_AFS_TRUE@LIB_kafs = -@KRB5_TRUE@LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la \ -@KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la - -@KRB5_TRUE@LIB_gssapi = $(top_builddir)/lib/gssapi/libgssapi.la -LIB_heimbase = $(top_builddir)/lib/base/libheimbase.la -@DCE_TRUE@LIB_kdfs = $(top_builddir)/lib/kdfs/libkdfs.la - -#silent-rules -heim_verbose = $(heim_verbose_$(V)) -heim_verbose_ = $(heim_verbose_$(AM_DEFAULT_VERBOSITY)) -heim_verbose_0 = @echo " GEN "$@; -ACLOCAL_AMFLAGS = -I ../../cf -CLEANFILES = roken.h make-roken.c $(XHEADERS) err.h fnmatch.h glob.h \ - ifaddrs.h search.h vis.h -lib_LTLIBRARIES = libroken.la -libroken_la_LDFLAGS = -version-info 19:0:1 $(am__append_1) -libroken_la_CPPFLAGS = -DBUILD_ROKEN_LIB -CHECK_LOCAL = snprintf-test resolve-test rkpty make-roken -TESTS = $(check_PROGRAMS) -LDADD = libroken.la -make_roken_LDADD = -noinst_LTLIBRARIES = libtest.la -libtest_la_SOURCES = strftime.c strptime.c snprintf.c tsearch.c -libtest_la_CFLAGS = -DTEST_SNPRINTF -DTEST_STRPFTIME -parse_reply_test_SOURCES = parse_reply-test.c resolve.c -parse_reply_test_CFLAGS = -DTEST_RESOLVE -test_readenv_SOURCES = test-readenv.c test-mem.c -test_detach_SOURCES = test-detach.c -rkpty_LDADD = $(LIB_openpty) $(LDADD) -parse_time_test_SOURCES = parse_time-test.c test-mem.c -strpftime_test_SOURCES = strpftime-test.c strpftime-test.h -strpftime_test_LDADD = libtest.la $(LDADD) -strpftime_test_CFLAGS = -DTEST_STRPFTIME -snprintf_test_SOURCES = snprintf-test.c -snprintf_test_LDADD = libtest.la $(LDADD) -snprintf_test_CFLAGS = -DTEST_SNPRINTF -tsearch_test_SOURCES = tsearch-test.c -tsearch_test_LDADD = libtest.la $(LDADD) -tsearch_test_CFLAGS = -DTEST_TSEARCH -getxxyyy_test_SOURCES = getxxyyy.c -getxxyyy_test_CFLAGS = -DTEST_GETXXYYY -resolve_test_SOURCES = resolve-test.c -libroken_la_SOURCES = base64.c bswap.c concat.c cloexec.c ct.c \ - detach.c doxygen.c dumpdata.c environment.c eread.c esetenv.c \ - ewrite.c getaddrinfo_hostspec.c get_default_username.c \ - get_window_size.c getarg.c getnameinfo_verified.c \ - getprogname.c getxxyyy.c h_errno.c hex.c hostent_find_fqdn.c \ - issuid.c k_getpwnam.c k_getpwuid.c mini_inetd.c mkdir.c \ - net_read.c net_write.c parse_bytes.c parse_time.c \ - parse_units.c qsort.c rand.c realloc.c resolve.c \ - roken_gethostby.c rtbl.c rtbl.h setprogname.c signal.c \ - simple_exec.c snprintf.c socket.c strcollect.c strerror_r.c \ - strpool.c timeval.c tm2time.c unvis.c verify.c vis.c warnerr.c \ - write_pid.c xfree.c xdbm.h $(am__append_3) -EXTRA_libroken_la_SOURCES = \ - err.hin \ - glob.hin \ - fnmatch.hin \ - ifaddrs.hin \ - search.hin \ - vis.hin - -libroken_la_LIBADD = @LTLIBOBJS@ $(LIB_crypt) $(LIB_pidfile) -BUILT_SOURCES = roken.h $(am__append_6) -@have_err_h_FALSE@err_h = err.h -@have_err_h_TRUE@err_h = -@have_fnmatch_h_FALSE@fnmatch_h = fnmatch.h -@have_fnmatch_h_TRUE@fnmatch_h = -@have_glob_h_FALSE@glob_h = glob.h -@have_glob_h_TRUE@glob_h = -@have_ifaddrs_h_FALSE@ifaddrs_h = ifaddrs.h -@have_ifaddrs_h_TRUE@ifaddrs_h = -@have_search_h_FALSE@search_h = search.h -@have_search_h_TRUE@search_h = -@have_vis_h_FALSE@vis_h = vis.h -@have_vis_h_TRUE@vis_h = -XHEADERS = $(err_h) $(fnmatch_h) $(glob_h) $(ifaddrs_h) $(search_h) $(vis_h) -dist_include_HEADERS = base64.h getarg.h hex.h parse_bytes.h \ - parse_time.h parse_units.h resolve.h roken-common.h rtbl.h \ - xdbm.h $(am__append_4) -build_HEADERZ = test-mem.h $(XHEADERS) -nodist_include_HEADERS = roken.h -rokenincludedir = $(includedir)/roken -nodist_rokeninclude_HEADERS = $(XHEADERS) -man_MANS = getarg.3 parse_time.3 rtbl.3 ecalloc.3 -@CROSS_COMPILE_FALSE@nodist_make_roken_SOURCES = make-roken.c -EXTRA_DIST = \ - NTMakefile \ - roken.awk roken.h.in \ - $(man_MANS) \ - dirent.c \ - dirent.hin \ - dirent-test.c \ - dlfcn.hin \ - dlfcn_w32.c \ - getifaddrs_w32.c \ - ndbm_wrap.c \ - ndbm_wrap.h \ - rename.c \ - simple_exec_w32.c \ - sleep.c \ - sockstartup_w32.c \ - stdbool.hin \ - stdint.hin \ - syslogc.c \ - syslog.hin \ - test-mem.h \ - test-mini_inetd.c \ - win32_alloc.c \ - version-script.map - -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am - -.SUFFIXES: -.SUFFIXES: .et .h .pc.in .pc .x .z .hx .1 .3 .5 .7 .8 .cat1 .cat3 .cat5 .cat7 .cat8 .hin .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/roken/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign lib/roken/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ - esac; -$(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(am__empty): - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -clean-noinstLTLIBRARIES: - -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) - @list='$(noinst_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libroken.la: $(libroken_la_OBJECTS) $(libroken_la_DEPENDENCIES) $(EXTRA_libroken_la_DEPENDENCIES) - $(AM_V_CCLD)$(libroken_la_LINK) -rpath $(libdir) $(libroken_la_OBJECTS) $(libroken_la_LIBADD) $(LIBS) - -libtest.la: $(libtest_la_OBJECTS) $(libtest_la_DEPENDENCIES) $(EXTRA_libtest_la_DEPENDENCIES) - $(AM_V_CCLD)$(libtest_la_LINK) $(libtest_la_OBJECTS) $(libtest_la_LIBADD) $(LIBS) - -base64-test$(EXEEXT): $(base64_test_OBJECTS) $(base64_test_DEPENDENCIES) $(EXTRA_base64_test_DEPENDENCIES) - @rm -f base64-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(base64_test_OBJECTS) $(base64_test_LDADD) $(LIBS) - -getaddrinfo-test$(EXEEXT): $(getaddrinfo_test_OBJECTS) $(getaddrinfo_test_DEPENDENCIES) $(EXTRA_getaddrinfo_test_DEPENDENCIES) - @rm -f getaddrinfo-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(getaddrinfo_test_OBJECTS) $(getaddrinfo_test_LDADD) $(LIBS) - -getifaddrs-test$(EXEEXT): $(getifaddrs_test_OBJECTS) $(getifaddrs_test_DEPENDENCIES) $(EXTRA_getifaddrs_test_DEPENDENCIES) - @rm -f getifaddrs-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(getifaddrs_test_OBJECTS) $(getifaddrs_test_LDADD) $(LIBS) - -getxxyyy-test$(EXEEXT): $(getxxyyy_test_OBJECTS) $(getxxyyy_test_DEPENDENCIES) $(EXTRA_getxxyyy_test_DEPENDENCIES) - @rm -f getxxyyy-test$(EXEEXT) - $(AM_V_CCLD)$(getxxyyy_test_LINK) $(getxxyyy_test_OBJECTS) $(getxxyyy_test_LDADD) $(LIBS) - -hex-test$(EXEEXT): $(hex_test_OBJECTS) $(hex_test_DEPENDENCIES) $(EXTRA_hex_test_DEPENDENCIES) - @rm -f hex-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(hex_test_OBJECTS) $(hex_test_LDADD) $(LIBS) - -make-roken$(EXEEXT): $(make_roken_OBJECTS) $(make_roken_DEPENDENCIES) $(EXTRA_make_roken_DEPENDENCIES) - @rm -f make-roken$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(make_roken_OBJECTS) $(make_roken_LDADD) $(LIBS) - -parse_bytes-test$(EXEEXT): $(parse_bytes_test_OBJECTS) $(parse_bytes_test_DEPENDENCIES) $(EXTRA_parse_bytes_test_DEPENDENCIES) - @rm -f parse_bytes-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(parse_bytes_test_OBJECTS) $(parse_bytes_test_LDADD) $(LIBS) - -parse_reply-test$(EXEEXT): $(parse_reply_test_OBJECTS) $(parse_reply_test_DEPENDENCIES) $(EXTRA_parse_reply_test_DEPENDENCIES) - @rm -f parse_reply-test$(EXEEXT) - $(AM_V_CCLD)$(parse_reply_test_LINK) $(parse_reply_test_OBJECTS) $(parse_reply_test_LDADD) $(LIBS) - -parse_time-test$(EXEEXT): $(parse_time_test_OBJECTS) $(parse_time_test_DEPENDENCIES) $(EXTRA_parse_time_test_DEPENDENCIES) - @rm -f parse_time-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(parse_time_test_OBJECTS) $(parse_time_test_LDADD) $(LIBS) - -resolve-test$(EXEEXT): $(resolve_test_OBJECTS) $(resolve_test_DEPENDENCIES) $(EXTRA_resolve_test_DEPENDENCIES) - @rm -f resolve-test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(resolve_test_OBJECTS) $(resolve_test_LDADD) $(LIBS) - -rkpty$(EXEEXT): $(rkpty_OBJECTS) $(rkpty_DEPENDENCIES) $(EXTRA_rkpty_DEPENDENCIES) - @rm -f rkpty$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(rkpty_OBJECTS) $(rkpty_LDADD) $(LIBS) - -snprintf-test$(EXEEXT): $(snprintf_test_OBJECTS) $(snprintf_test_DEPENDENCIES) $(EXTRA_snprintf_test_DEPENDENCIES) - @rm -f snprintf-test$(EXEEXT) - $(AM_V_CCLD)$(snprintf_test_LINK) $(snprintf_test_OBJECTS) $(snprintf_test_LDADD) $(LIBS) - -strpftime-test$(EXEEXT): $(strpftime_test_OBJECTS) $(strpftime_test_DEPENDENCIES) $(EXTRA_strpftime_test_DEPENDENCIES) - @rm -f strpftime-test$(EXEEXT) - $(AM_V_CCLD)$(strpftime_test_LINK) $(strpftime_test_OBJECTS) $(strpftime_test_LDADD) $(LIBS) - -test-detach$(EXEEXT): $(test_detach_OBJECTS) $(test_detach_DEPENDENCIES) $(EXTRA_test_detach_DEPENDENCIES) - @rm -f test-detach$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_detach_OBJECTS) $(test_detach_LDADD) $(LIBS) - -test-readenv$(EXEEXT): $(test_readenv_OBJECTS) $(test_readenv_DEPENDENCIES) $(EXTRA_test_readenv_DEPENDENCIES) - @rm -f test-readenv$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(test_readenv_OBJECTS) $(test_readenv_LDADD) $(LIBS) - -tsearch-test$(EXEEXT): $(tsearch_test_OBJECTS) $(tsearch_test_DEPENDENCIES) $(EXTRA_tsearch_test_DEPENDENCIES) - @rm -f tsearch-test$(EXEEXT) - $(AM_V_CCLD)$(tsearch_test_LINK) $(tsearch_test_OBJECTS) $(tsearch_test_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chown.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/closefrom.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/copyhostent.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/daemon.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ecalloc.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/emalloc.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/erealloc.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/err.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/errx.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/estrdup.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fchown.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/flock.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fnmatch.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/freeaddrinfo.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/freehostent.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gai_strerror.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getaddrinfo.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getcap.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getcwd.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getdtablesize.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getegid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/geteuid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getgid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gethostname.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getifaddrs.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getipnodebyaddr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getipnodebyname.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getnameinfo.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gettimeofday.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getuid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getusershell.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/glob.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/hstrerror.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_aton.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_ntop.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_pton.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/initgroups.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/innetgr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/iruserok.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/localtime_r.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/lstat.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/memmove.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/memset_s.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mkstemp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/putenv.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rcmd.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/readv.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/recvmsg.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sendmsg.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setegid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setenv.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/seteuid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasecmp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strdup.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strerror.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strftime.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlwr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strncasecmp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strndup.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strnlen.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strptime.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strsep.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strsep_copy.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtok_r.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoll.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoull.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strupr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/swab.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/timegm.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/tsearch.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/unsetenv.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/verr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/verrx.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vsyslog.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vwarn.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vwarnx.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/warn.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/warnx.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/writev.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getaddrinfo-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getifaddrs-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getxxyyy_test-getxxyyy.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hex-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-base64.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-bswap.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-cloexec.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-concat.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-ct.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-detach.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-doxygen.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-dumpdata.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-environment.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-eread.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-esetenv.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-ewrite.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-get_default_username.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-get_window_size.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-getaddrinfo_hostspec.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-getarg.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-getnameinfo_verified.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-getprogname.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-getxxyyy.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-h_errno.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-hex.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-hostent_find_fqdn.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-issuid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-k_getpwnam.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-k_getpwuid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-mini_inetd.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-mkdir.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-net_read.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-net_write.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-parse_bytes.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-parse_time.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-parse_units.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-qsort.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-rand.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-realloc.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-resolve.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-roken_gethostby.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-rtbl.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-setprogname.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-signal.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-simple_exec.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-snprintf.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-socket.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-socket_wrapper.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-strcollect.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-strerror_r.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-strpool.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-timeval.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-tm2time.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-unvis.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-verify.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-vis.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-warnerr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-write_pid.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libroken_la-xfree.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_la-snprintf.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_la-strftime.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_la-strptime.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_la-tsearch.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/make-roken.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_bytes-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_reply_test-parse_reply-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_reply_test-resolve.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_time-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolve-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rkpty.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf_test-snprintf-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strpftime_test-strpftime-test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-detach.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mem.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-readenv.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsearch_test-tsearch-test.Po@am__quote@ # am--include-marker - -$(am__depfiles_remade): - @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ - -am--depfiles: $(am__depfiles_remade) - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -libroken_la-base64.lo: base64.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-base64.lo -MD -MP -MF $(DEPDIR)/libroken_la-base64.Tpo -c -o libroken_la-base64.lo `test -f 'base64.c' || echo '$(srcdir)/'`base64.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-base64.Tpo $(DEPDIR)/libroken_la-base64.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='base64.c' object='libroken_la-base64.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-base64.lo `test -f 'base64.c' || echo '$(srcdir)/'`base64.c - -libroken_la-bswap.lo: bswap.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-bswap.lo -MD -MP -MF $(DEPDIR)/libroken_la-bswap.Tpo -c -o libroken_la-bswap.lo `test -f 'bswap.c' || echo '$(srcdir)/'`bswap.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-bswap.Tpo $(DEPDIR)/libroken_la-bswap.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bswap.c' object='libroken_la-bswap.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-bswap.lo `test -f 'bswap.c' || echo '$(srcdir)/'`bswap.c - -libroken_la-concat.lo: concat.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-concat.lo -MD -MP -MF $(DEPDIR)/libroken_la-concat.Tpo -c -o libroken_la-concat.lo `test -f 'concat.c' || echo '$(srcdir)/'`concat.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-concat.Tpo $(DEPDIR)/libroken_la-concat.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concat.c' object='libroken_la-concat.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-concat.lo `test -f 'concat.c' || echo '$(srcdir)/'`concat.c - -libroken_la-cloexec.lo: cloexec.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-cloexec.lo -MD -MP -MF $(DEPDIR)/libroken_la-cloexec.Tpo -c -o libroken_la-cloexec.lo `test -f 'cloexec.c' || echo '$(srcdir)/'`cloexec.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-cloexec.Tpo $(DEPDIR)/libroken_la-cloexec.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cloexec.c' object='libroken_la-cloexec.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-cloexec.lo `test -f 'cloexec.c' || echo '$(srcdir)/'`cloexec.c - -libroken_la-ct.lo: ct.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-ct.lo -MD -MP -MF $(DEPDIR)/libroken_la-ct.Tpo -c -o libroken_la-ct.lo `test -f 'ct.c' || echo '$(srcdir)/'`ct.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-ct.Tpo $(DEPDIR)/libroken_la-ct.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ct.c' object='libroken_la-ct.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-ct.lo `test -f 'ct.c' || echo '$(srcdir)/'`ct.c - -libroken_la-detach.lo: detach.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-detach.lo -MD -MP -MF $(DEPDIR)/libroken_la-detach.Tpo -c -o libroken_la-detach.lo `test -f 'detach.c' || echo '$(srcdir)/'`detach.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-detach.Tpo $(DEPDIR)/libroken_la-detach.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='detach.c' object='libroken_la-detach.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-detach.lo `test -f 'detach.c' || echo '$(srcdir)/'`detach.c - -libroken_la-doxygen.lo: doxygen.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-doxygen.lo -MD -MP -MF $(DEPDIR)/libroken_la-doxygen.Tpo -c -o libroken_la-doxygen.lo `test -f 'doxygen.c' || echo '$(srcdir)/'`doxygen.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-doxygen.Tpo $(DEPDIR)/libroken_la-doxygen.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='doxygen.c' object='libroken_la-doxygen.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-doxygen.lo `test -f 'doxygen.c' || echo '$(srcdir)/'`doxygen.c - -libroken_la-dumpdata.lo: dumpdata.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-dumpdata.lo -MD -MP -MF $(DEPDIR)/libroken_la-dumpdata.Tpo -c -o libroken_la-dumpdata.lo `test -f 'dumpdata.c' || echo '$(srcdir)/'`dumpdata.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-dumpdata.Tpo $(DEPDIR)/libroken_la-dumpdata.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dumpdata.c' object='libroken_la-dumpdata.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-dumpdata.lo `test -f 'dumpdata.c' || echo '$(srcdir)/'`dumpdata.c - -libroken_la-environment.lo: environment.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-environment.lo -MD -MP -MF $(DEPDIR)/libroken_la-environment.Tpo -c -o libroken_la-environment.lo `test -f 'environment.c' || echo '$(srcdir)/'`environment.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-environment.Tpo $(DEPDIR)/libroken_la-environment.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='environment.c' object='libroken_la-environment.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-environment.lo `test -f 'environment.c' || echo '$(srcdir)/'`environment.c - -libroken_la-eread.lo: eread.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-eread.lo -MD -MP -MF $(DEPDIR)/libroken_la-eread.Tpo -c -o libroken_la-eread.lo `test -f 'eread.c' || echo '$(srcdir)/'`eread.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-eread.Tpo $(DEPDIR)/libroken_la-eread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='eread.c' object='libroken_la-eread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-eread.lo `test -f 'eread.c' || echo '$(srcdir)/'`eread.c - -libroken_la-esetenv.lo: esetenv.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-esetenv.lo -MD -MP -MF $(DEPDIR)/libroken_la-esetenv.Tpo -c -o libroken_la-esetenv.lo `test -f 'esetenv.c' || echo '$(srcdir)/'`esetenv.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-esetenv.Tpo $(DEPDIR)/libroken_la-esetenv.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='esetenv.c' object='libroken_la-esetenv.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-esetenv.lo `test -f 'esetenv.c' || echo '$(srcdir)/'`esetenv.c - -libroken_la-ewrite.lo: ewrite.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-ewrite.lo -MD -MP -MF $(DEPDIR)/libroken_la-ewrite.Tpo -c -o libroken_la-ewrite.lo `test -f 'ewrite.c' || echo '$(srcdir)/'`ewrite.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-ewrite.Tpo $(DEPDIR)/libroken_la-ewrite.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ewrite.c' object='libroken_la-ewrite.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-ewrite.lo `test -f 'ewrite.c' || echo '$(srcdir)/'`ewrite.c - -libroken_la-getaddrinfo_hostspec.lo: getaddrinfo_hostspec.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-getaddrinfo_hostspec.lo -MD -MP -MF $(DEPDIR)/libroken_la-getaddrinfo_hostspec.Tpo -c -o libroken_la-getaddrinfo_hostspec.lo `test -f 'getaddrinfo_hostspec.c' || echo '$(srcdir)/'`getaddrinfo_hostspec.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-getaddrinfo_hostspec.Tpo $(DEPDIR)/libroken_la-getaddrinfo_hostspec.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getaddrinfo_hostspec.c' object='libroken_la-getaddrinfo_hostspec.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-getaddrinfo_hostspec.lo `test -f 'getaddrinfo_hostspec.c' || echo '$(srcdir)/'`getaddrinfo_hostspec.c - -libroken_la-get_default_username.lo: get_default_username.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-get_default_username.lo -MD -MP -MF $(DEPDIR)/libroken_la-get_default_username.Tpo -c -o libroken_la-get_default_username.lo `test -f 'get_default_username.c' || echo '$(srcdir)/'`get_default_username.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-get_default_username.Tpo $(DEPDIR)/libroken_la-get_default_username.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='get_default_username.c' object='libroken_la-get_default_username.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-get_default_username.lo `test -f 'get_default_username.c' || echo '$(srcdir)/'`get_default_username.c - -libroken_la-get_window_size.lo: get_window_size.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-get_window_size.lo -MD -MP -MF $(DEPDIR)/libroken_la-get_window_size.Tpo -c -o libroken_la-get_window_size.lo `test -f 'get_window_size.c' || echo '$(srcdir)/'`get_window_size.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-get_window_size.Tpo $(DEPDIR)/libroken_la-get_window_size.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='get_window_size.c' object='libroken_la-get_window_size.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-get_window_size.lo `test -f 'get_window_size.c' || echo '$(srcdir)/'`get_window_size.c - -libroken_la-getarg.lo: getarg.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-getarg.lo -MD -MP -MF $(DEPDIR)/libroken_la-getarg.Tpo -c -o libroken_la-getarg.lo `test -f 'getarg.c' || echo '$(srcdir)/'`getarg.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-getarg.Tpo $(DEPDIR)/libroken_la-getarg.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getarg.c' object='libroken_la-getarg.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-getarg.lo `test -f 'getarg.c' || echo '$(srcdir)/'`getarg.c - -libroken_la-getnameinfo_verified.lo: getnameinfo_verified.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-getnameinfo_verified.lo -MD -MP -MF $(DEPDIR)/libroken_la-getnameinfo_verified.Tpo -c -o libroken_la-getnameinfo_verified.lo `test -f 'getnameinfo_verified.c' || echo '$(srcdir)/'`getnameinfo_verified.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-getnameinfo_verified.Tpo $(DEPDIR)/libroken_la-getnameinfo_verified.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getnameinfo_verified.c' object='libroken_la-getnameinfo_verified.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-getnameinfo_verified.lo `test -f 'getnameinfo_verified.c' || echo '$(srcdir)/'`getnameinfo_verified.c - -libroken_la-getprogname.lo: getprogname.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-getprogname.lo -MD -MP -MF $(DEPDIR)/libroken_la-getprogname.Tpo -c -o libroken_la-getprogname.lo `test -f 'getprogname.c' || echo '$(srcdir)/'`getprogname.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-getprogname.Tpo $(DEPDIR)/libroken_la-getprogname.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getprogname.c' object='libroken_la-getprogname.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-getprogname.lo `test -f 'getprogname.c' || echo '$(srcdir)/'`getprogname.c - -libroken_la-getxxyyy.lo: getxxyyy.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-getxxyyy.lo -MD -MP -MF $(DEPDIR)/libroken_la-getxxyyy.Tpo -c -o libroken_la-getxxyyy.lo `test -f 'getxxyyy.c' || echo '$(srcdir)/'`getxxyyy.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-getxxyyy.Tpo $(DEPDIR)/libroken_la-getxxyyy.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getxxyyy.c' object='libroken_la-getxxyyy.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-getxxyyy.lo `test -f 'getxxyyy.c' || echo '$(srcdir)/'`getxxyyy.c - -libroken_la-h_errno.lo: h_errno.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-h_errno.lo -MD -MP -MF $(DEPDIR)/libroken_la-h_errno.Tpo -c -o libroken_la-h_errno.lo `test -f 'h_errno.c' || echo '$(srcdir)/'`h_errno.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-h_errno.Tpo $(DEPDIR)/libroken_la-h_errno.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='h_errno.c' object='libroken_la-h_errno.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-h_errno.lo `test -f 'h_errno.c' || echo '$(srcdir)/'`h_errno.c - -libroken_la-hex.lo: hex.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-hex.lo -MD -MP -MF $(DEPDIR)/libroken_la-hex.Tpo -c -o libroken_la-hex.lo `test -f 'hex.c' || echo '$(srcdir)/'`hex.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-hex.Tpo $(DEPDIR)/libroken_la-hex.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hex.c' object='libroken_la-hex.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-hex.lo `test -f 'hex.c' || echo '$(srcdir)/'`hex.c - -libroken_la-hostent_find_fqdn.lo: hostent_find_fqdn.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-hostent_find_fqdn.lo -MD -MP -MF $(DEPDIR)/libroken_la-hostent_find_fqdn.Tpo -c -o libroken_la-hostent_find_fqdn.lo `test -f 'hostent_find_fqdn.c' || echo '$(srcdir)/'`hostent_find_fqdn.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-hostent_find_fqdn.Tpo $(DEPDIR)/libroken_la-hostent_find_fqdn.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hostent_find_fqdn.c' object='libroken_la-hostent_find_fqdn.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-hostent_find_fqdn.lo `test -f 'hostent_find_fqdn.c' || echo '$(srcdir)/'`hostent_find_fqdn.c - -libroken_la-issuid.lo: issuid.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-issuid.lo -MD -MP -MF $(DEPDIR)/libroken_la-issuid.Tpo -c -o libroken_la-issuid.lo `test -f 'issuid.c' || echo '$(srcdir)/'`issuid.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-issuid.Tpo $(DEPDIR)/libroken_la-issuid.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='issuid.c' object='libroken_la-issuid.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-issuid.lo `test -f 'issuid.c' || echo '$(srcdir)/'`issuid.c - -libroken_la-k_getpwnam.lo: k_getpwnam.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-k_getpwnam.lo -MD -MP -MF $(DEPDIR)/libroken_la-k_getpwnam.Tpo -c -o libroken_la-k_getpwnam.lo `test -f 'k_getpwnam.c' || echo '$(srcdir)/'`k_getpwnam.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-k_getpwnam.Tpo $(DEPDIR)/libroken_la-k_getpwnam.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='k_getpwnam.c' object='libroken_la-k_getpwnam.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-k_getpwnam.lo `test -f 'k_getpwnam.c' || echo '$(srcdir)/'`k_getpwnam.c - -libroken_la-k_getpwuid.lo: k_getpwuid.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-k_getpwuid.lo -MD -MP -MF $(DEPDIR)/libroken_la-k_getpwuid.Tpo -c -o libroken_la-k_getpwuid.lo `test -f 'k_getpwuid.c' || echo '$(srcdir)/'`k_getpwuid.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-k_getpwuid.Tpo $(DEPDIR)/libroken_la-k_getpwuid.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='k_getpwuid.c' object='libroken_la-k_getpwuid.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-k_getpwuid.lo `test -f 'k_getpwuid.c' || echo '$(srcdir)/'`k_getpwuid.c - -libroken_la-mini_inetd.lo: mini_inetd.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-mini_inetd.lo -MD -MP -MF $(DEPDIR)/libroken_la-mini_inetd.Tpo -c -o libroken_la-mini_inetd.lo `test -f 'mini_inetd.c' || echo '$(srcdir)/'`mini_inetd.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-mini_inetd.Tpo $(DEPDIR)/libroken_la-mini_inetd.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mini_inetd.c' object='libroken_la-mini_inetd.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-mini_inetd.lo `test -f 'mini_inetd.c' || echo '$(srcdir)/'`mini_inetd.c - -libroken_la-mkdir.lo: mkdir.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-mkdir.lo -MD -MP -MF $(DEPDIR)/libroken_la-mkdir.Tpo -c -o libroken_la-mkdir.lo `test -f 'mkdir.c' || echo '$(srcdir)/'`mkdir.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-mkdir.Tpo $(DEPDIR)/libroken_la-mkdir.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mkdir.c' object='libroken_la-mkdir.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-mkdir.lo `test -f 'mkdir.c' || echo '$(srcdir)/'`mkdir.c - -libroken_la-net_read.lo: net_read.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-net_read.lo -MD -MP -MF $(DEPDIR)/libroken_la-net_read.Tpo -c -o libroken_la-net_read.lo `test -f 'net_read.c' || echo '$(srcdir)/'`net_read.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-net_read.Tpo $(DEPDIR)/libroken_la-net_read.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net_read.c' object='libroken_la-net_read.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-net_read.lo `test -f 'net_read.c' || echo '$(srcdir)/'`net_read.c - -libroken_la-net_write.lo: net_write.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-net_write.lo -MD -MP -MF $(DEPDIR)/libroken_la-net_write.Tpo -c -o libroken_la-net_write.lo `test -f 'net_write.c' || echo '$(srcdir)/'`net_write.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-net_write.Tpo $(DEPDIR)/libroken_la-net_write.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='net_write.c' object='libroken_la-net_write.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-net_write.lo `test -f 'net_write.c' || echo '$(srcdir)/'`net_write.c - -libroken_la-parse_bytes.lo: parse_bytes.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-parse_bytes.lo -MD -MP -MF $(DEPDIR)/libroken_la-parse_bytes.Tpo -c -o libroken_la-parse_bytes.lo `test -f 'parse_bytes.c' || echo '$(srcdir)/'`parse_bytes.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-parse_bytes.Tpo $(DEPDIR)/libroken_la-parse_bytes.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parse_bytes.c' object='libroken_la-parse_bytes.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-parse_bytes.lo `test -f 'parse_bytes.c' || echo '$(srcdir)/'`parse_bytes.c - -libroken_la-parse_time.lo: parse_time.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-parse_time.lo -MD -MP -MF $(DEPDIR)/libroken_la-parse_time.Tpo -c -o libroken_la-parse_time.lo `test -f 'parse_time.c' || echo '$(srcdir)/'`parse_time.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-parse_time.Tpo $(DEPDIR)/libroken_la-parse_time.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parse_time.c' object='libroken_la-parse_time.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-parse_time.lo `test -f 'parse_time.c' || echo '$(srcdir)/'`parse_time.c - -libroken_la-parse_units.lo: parse_units.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-parse_units.lo -MD -MP -MF $(DEPDIR)/libroken_la-parse_units.Tpo -c -o libroken_la-parse_units.lo `test -f 'parse_units.c' || echo '$(srcdir)/'`parse_units.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-parse_units.Tpo $(DEPDIR)/libroken_la-parse_units.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parse_units.c' object='libroken_la-parse_units.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-parse_units.lo `test -f 'parse_units.c' || echo '$(srcdir)/'`parse_units.c - -libroken_la-qsort.lo: qsort.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-qsort.lo -MD -MP -MF $(DEPDIR)/libroken_la-qsort.Tpo -c -o libroken_la-qsort.lo `test -f 'qsort.c' || echo '$(srcdir)/'`qsort.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-qsort.Tpo $(DEPDIR)/libroken_la-qsort.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='qsort.c' object='libroken_la-qsort.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-qsort.lo `test -f 'qsort.c' || echo '$(srcdir)/'`qsort.c - -libroken_la-rand.lo: rand.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-rand.lo -MD -MP -MF $(DEPDIR)/libroken_la-rand.Tpo -c -o libroken_la-rand.lo `test -f 'rand.c' || echo '$(srcdir)/'`rand.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-rand.Tpo $(DEPDIR)/libroken_la-rand.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rand.c' object='libroken_la-rand.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-rand.lo `test -f 'rand.c' || echo '$(srcdir)/'`rand.c - -libroken_la-realloc.lo: realloc.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-realloc.lo -MD -MP -MF $(DEPDIR)/libroken_la-realloc.Tpo -c -o libroken_la-realloc.lo `test -f 'realloc.c' || echo '$(srcdir)/'`realloc.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-realloc.Tpo $(DEPDIR)/libroken_la-realloc.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='realloc.c' object='libroken_la-realloc.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-realloc.lo `test -f 'realloc.c' || echo '$(srcdir)/'`realloc.c - -libroken_la-resolve.lo: resolve.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-resolve.lo -MD -MP -MF $(DEPDIR)/libroken_la-resolve.Tpo -c -o libroken_la-resolve.lo `test -f 'resolve.c' || echo '$(srcdir)/'`resolve.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-resolve.Tpo $(DEPDIR)/libroken_la-resolve.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='resolve.c' object='libroken_la-resolve.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-resolve.lo `test -f 'resolve.c' || echo '$(srcdir)/'`resolve.c - -libroken_la-roken_gethostby.lo: roken_gethostby.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-roken_gethostby.lo -MD -MP -MF $(DEPDIR)/libroken_la-roken_gethostby.Tpo -c -o libroken_la-roken_gethostby.lo `test -f 'roken_gethostby.c' || echo '$(srcdir)/'`roken_gethostby.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-roken_gethostby.Tpo $(DEPDIR)/libroken_la-roken_gethostby.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='roken_gethostby.c' object='libroken_la-roken_gethostby.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-roken_gethostby.lo `test -f 'roken_gethostby.c' || echo '$(srcdir)/'`roken_gethostby.c - -libroken_la-rtbl.lo: rtbl.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-rtbl.lo -MD -MP -MF $(DEPDIR)/libroken_la-rtbl.Tpo -c -o libroken_la-rtbl.lo `test -f 'rtbl.c' || echo '$(srcdir)/'`rtbl.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-rtbl.Tpo $(DEPDIR)/libroken_la-rtbl.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='rtbl.c' object='libroken_la-rtbl.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-rtbl.lo `test -f 'rtbl.c' || echo '$(srcdir)/'`rtbl.c - -libroken_la-setprogname.lo: setprogname.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-setprogname.lo -MD -MP -MF $(DEPDIR)/libroken_la-setprogname.Tpo -c -o libroken_la-setprogname.lo `test -f 'setprogname.c' || echo '$(srcdir)/'`setprogname.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-setprogname.Tpo $(DEPDIR)/libroken_la-setprogname.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='setprogname.c' object='libroken_la-setprogname.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-setprogname.lo `test -f 'setprogname.c' || echo '$(srcdir)/'`setprogname.c - -libroken_la-signal.lo: signal.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-signal.lo -MD -MP -MF $(DEPDIR)/libroken_la-signal.Tpo -c -o libroken_la-signal.lo `test -f 'signal.c' || echo '$(srcdir)/'`signal.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-signal.Tpo $(DEPDIR)/libroken_la-signal.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='signal.c' object='libroken_la-signal.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-signal.lo `test -f 'signal.c' || echo '$(srcdir)/'`signal.c - -libroken_la-simple_exec.lo: simple_exec.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-simple_exec.lo -MD -MP -MF $(DEPDIR)/libroken_la-simple_exec.Tpo -c -o libroken_la-simple_exec.lo `test -f 'simple_exec.c' || echo '$(srcdir)/'`simple_exec.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-simple_exec.Tpo $(DEPDIR)/libroken_la-simple_exec.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='simple_exec.c' object='libroken_la-simple_exec.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-simple_exec.lo `test -f 'simple_exec.c' || echo '$(srcdir)/'`simple_exec.c - -libroken_la-snprintf.lo: snprintf.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-snprintf.lo -MD -MP -MF $(DEPDIR)/libroken_la-snprintf.Tpo -c -o libroken_la-snprintf.lo `test -f 'snprintf.c' || echo '$(srcdir)/'`snprintf.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-snprintf.Tpo $(DEPDIR)/libroken_la-snprintf.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='snprintf.c' object='libroken_la-snprintf.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-snprintf.lo `test -f 'snprintf.c' || echo '$(srcdir)/'`snprintf.c - -libroken_la-socket.lo: socket.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-socket.lo -MD -MP -MF $(DEPDIR)/libroken_la-socket.Tpo -c -o libroken_la-socket.lo `test -f 'socket.c' || echo '$(srcdir)/'`socket.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-socket.Tpo $(DEPDIR)/libroken_la-socket.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket.c' object='libroken_la-socket.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-socket.lo `test -f 'socket.c' || echo '$(srcdir)/'`socket.c - -libroken_la-strcollect.lo: strcollect.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-strcollect.lo -MD -MP -MF $(DEPDIR)/libroken_la-strcollect.Tpo -c -o libroken_la-strcollect.lo `test -f 'strcollect.c' || echo '$(srcdir)/'`strcollect.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-strcollect.Tpo $(DEPDIR)/libroken_la-strcollect.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strcollect.c' object='libroken_la-strcollect.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-strcollect.lo `test -f 'strcollect.c' || echo '$(srcdir)/'`strcollect.c - -libroken_la-strerror_r.lo: strerror_r.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-strerror_r.lo -MD -MP -MF $(DEPDIR)/libroken_la-strerror_r.Tpo -c -o libroken_la-strerror_r.lo `test -f 'strerror_r.c' || echo '$(srcdir)/'`strerror_r.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-strerror_r.Tpo $(DEPDIR)/libroken_la-strerror_r.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strerror_r.c' object='libroken_la-strerror_r.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-strerror_r.lo `test -f 'strerror_r.c' || echo '$(srcdir)/'`strerror_r.c - -libroken_la-strpool.lo: strpool.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-strpool.lo -MD -MP -MF $(DEPDIR)/libroken_la-strpool.Tpo -c -o libroken_la-strpool.lo `test -f 'strpool.c' || echo '$(srcdir)/'`strpool.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-strpool.Tpo $(DEPDIR)/libroken_la-strpool.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strpool.c' object='libroken_la-strpool.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-strpool.lo `test -f 'strpool.c' || echo '$(srcdir)/'`strpool.c - -libroken_la-timeval.lo: timeval.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-timeval.lo -MD -MP -MF $(DEPDIR)/libroken_la-timeval.Tpo -c -o libroken_la-timeval.lo `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-timeval.Tpo $(DEPDIR)/libroken_la-timeval.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timeval.c' object='libroken_la-timeval.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-timeval.lo `test -f 'timeval.c' || echo '$(srcdir)/'`timeval.c - -libroken_la-tm2time.lo: tm2time.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-tm2time.lo -MD -MP -MF $(DEPDIR)/libroken_la-tm2time.Tpo -c -o libroken_la-tm2time.lo `test -f 'tm2time.c' || echo '$(srcdir)/'`tm2time.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-tm2time.Tpo $(DEPDIR)/libroken_la-tm2time.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tm2time.c' object='libroken_la-tm2time.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-tm2time.lo `test -f 'tm2time.c' || echo '$(srcdir)/'`tm2time.c - -libroken_la-unvis.lo: unvis.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-unvis.lo -MD -MP -MF $(DEPDIR)/libroken_la-unvis.Tpo -c -o libroken_la-unvis.lo `test -f 'unvis.c' || echo '$(srcdir)/'`unvis.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-unvis.Tpo $(DEPDIR)/libroken_la-unvis.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='unvis.c' object='libroken_la-unvis.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-unvis.lo `test -f 'unvis.c' || echo '$(srcdir)/'`unvis.c - -libroken_la-verify.lo: verify.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-verify.lo -MD -MP -MF $(DEPDIR)/libroken_la-verify.Tpo -c -o libroken_la-verify.lo `test -f 'verify.c' || echo '$(srcdir)/'`verify.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-verify.Tpo $(DEPDIR)/libroken_la-verify.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='verify.c' object='libroken_la-verify.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-verify.lo `test -f 'verify.c' || echo '$(srcdir)/'`verify.c - -libroken_la-vis.lo: vis.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-vis.lo -MD -MP -MF $(DEPDIR)/libroken_la-vis.Tpo -c -o libroken_la-vis.lo `test -f 'vis.c' || echo '$(srcdir)/'`vis.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-vis.Tpo $(DEPDIR)/libroken_la-vis.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vis.c' object='libroken_la-vis.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-vis.lo `test -f 'vis.c' || echo '$(srcdir)/'`vis.c - -libroken_la-warnerr.lo: warnerr.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-warnerr.lo -MD -MP -MF $(DEPDIR)/libroken_la-warnerr.Tpo -c -o libroken_la-warnerr.lo `test -f 'warnerr.c' || echo '$(srcdir)/'`warnerr.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-warnerr.Tpo $(DEPDIR)/libroken_la-warnerr.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='warnerr.c' object='libroken_la-warnerr.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-warnerr.lo `test -f 'warnerr.c' || echo '$(srcdir)/'`warnerr.c - -libroken_la-write_pid.lo: write_pid.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-write_pid.lo -MD -MP -MF $(DEPDIR)/libroken_la-write_pid.Tpo -c -o libroken_la-write_pid.lo `test -f 'write_pid.c' || echo '$(srcdir)/'`write_pid.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-write_pid.Tpo $(DEPDIR)/libroken_la-write_pid.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='write_pid.c' object='libroken_la-write_pid.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-write_pid.lo `test -f 'write_pid.c' || echo '$(srcdir)/'`write_pid.c - -libroken_la-xfree.lo: xfree.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-xfree.lo -MD -MP -MF $(DEPDIR)/libroken_la-xfree.Tpo -c -o libroken_la-xfree.lo `test -f 'xfree.c' || echo '$(srcdir)/'`xfree.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-xfree.Tpo $(DEPDIR)/libroken_la-xfree.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xfree.c' object='libroken_la-xfree.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-xfree.lo `test -f 'xfree.c' || echo '$(srcdir)/'`xfree.c - -libroken_la-socket_wrapper.lo: socket_wrapper.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libroken_la-socket_wrapper.lo -MD -MP -MF $(DEPDIR)/libroken_la-socket_wrapper.Tpo -c -o libroken_la-socket_wrapper.lo `test -f 'socket_wrapper.c' || echo '$(srcdir)/'`socket_wrapper.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libroken_la-socket_wrapper.Tpo $(DEPDIR)/libroken_la-socket_wrapper.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket_wrapper.c' object='libroken_la-socket_wrapper.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libroken_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libroken_la-socket_wrapper.lo `test -f 'socket_wrapper.c' || echo '$(srcdir)/'`socket_wrapper.c - -libtest_la-strftime.lo: strftime.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT libtest_la-strftime.lo -MD -MP -MF $(DEPDIR)/libtest_la-strftime.Tpo -c -o libtest_la-strftime.lo `test -f 'strftime.c' || echo '$(srcdir)/'`strftime.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_la-strftime.Tpo $(DEPDIR)/libtest_la-strftime.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strftime.c' object='libtest_la-strftime.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o libtest_la-strftime.lo `test -f 'strftime.c' || echo '$(srcdir)/'`strftime.c - -libtest_la-strptime.lo: strptime.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT libtest_la-strptime.lo -MD -MP -MF $(DEPDIR)/libtest_la-strptime.Tpo -c -o libtest_la-strptime.lo `test -f 'strptime.c' || echo '$(srcdir)/'`strptime.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_la-strptime.Tpo $(DEPDIR)/libtest_la-strptime.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strptime.c' object='libtest_la-strptime.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o libtest_la-strptime.lo `test -f 'strptime.c' || echo '$(srcdir)/'`strptime.c - -libtest_la-snprintf.lo: snprintf.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT libtest_la-snprintf.lo -MD -MP -MF $(DEPDIR)/libtest_la-snprintf.Tpo -c -o libtest_la-snprintf.lo `test -f 'snprintf.c' || echo '$(srcdir)/'`snprintf.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_la-snprintf.Tpo $(DEPDIR)/libtest_la-snprintf.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='snprintf.c' object='libtest_la-snprintf.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o libtest_la-snprintf.lo `test -f 'snprintf.c' || echo '$(srcdir)/'`snprintf.c - -libtest_la-tsearch.lo: tsearch.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT libtest_la-tsearch.lo -MD -MP -MF $(DEPDIR)/libtest_la-tsearch.Tpo -c -o libtest_la-tsearch.lo `test -f 'tsearch.c' || echo '$(srcdir)/'`tsearch.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_la-tsearch.Tpo $(DEPDIR)/libtest_la-tsearch.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tsearch.c' object='libtest_la-tsearch.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o libtest_la-tsearch.lo `test -f 'tsearch.c' || echo '$(srcdir)/'`tsearch.c - -getxxyyy_test-getxxyyy.o: getxxyyy.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getxxyyy_test_CFLAGS) $(CFLAGS) -MT getxxyyy_test-getxxyyy.o -MD -MP -MF $(DEPDIR)/getxxyyy_test-getxxyyy.Tpo -c -o getxxyyy_test-getxxyyy.o `test -f 'getxxyyy.c' || echo '$(srcdir)/'`getxxyyy.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getxxyyy_test-getxxyyy.Tpo $(DEPDIR)/getxxyyy_test-getxxyyy.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getxxyyy.c' object='getxxyyy_test-getxxyyy.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getxxyyy_test_CFLAGS) $(CFLAGS) -c -o getxxyyy_test-getxxyyy.o `test -f 'getxxyyy.c' || echo '$(srcdir)/'`getxxyyy.c - -getxxyyy_test-getxxyyy.obj: getxxyyy.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getxxyyy_test_CFLAGS) $(CFLAGS) -MT getxxyyy_test-getxxyyy.obj -MD -MP -MF $(DEPDIR)/getxxyyy_test-getxxyyy.Tpo -c -o getxxyyy_test-getxxyyy.obj `if test -f 'getxxyyy.c'; then $(CYGPATH_W) 'getxxyyy.c'; else $(CYGPATH_W) '$(srcdir)/getxxyyy.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getxxyyy_test-getxxyyy.Tpo $(DEPDIR)/getxxyyy_test-getxxyyy.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getxxyyy.c' object='getxxyyy_test-getxxyyy.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getxxyyy_test_CFLAGS) $(CFLAGS) -c -o getxxyyy_test-getxxyyy.obj `if test -f 'getxxyyy.c'; then $(CYGPATH_W) 'getxxyyy.c'; else $(CYGPATH_W) '$(srcdir)/getxxyyy.c'; fi` - -parse_reply_test-parse_reply-test.o: parse_reply-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -MT parse_reply_test-parse_reply-test.o -MD -MP -MF $(DEPDIR)/parse_reply_test-parse_reply-test.Tpo -c -o parse_reply_test-parse_reply-test.o `test -f 'parse_reply-test.c' || echo '$(srcdir)/'`parse_reply-test.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/parse_reply_test-parse_reply-test.Tpo $(DEPDIR)/parse_reply_test-parse_reply-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parse_reply-test.c' object='parse_reply_test-parse_reply-test.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -c -o parse_reply_test-parse_reply-test.o `test -f 'parse_reply-test.c' || echo '$(srcdir)/'`parse_reply-test.c - -parse_reply_test-parse_reply-test.obj: parse_reply-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -MT parse_reply_test-parse_reply-test.obj -MD -MP -MF $(DEPDIR)/parse_reply_test-parse_reply-test.Tpo -c -o parse_reply_test-parse_reply-test.obj `if test -f 'parse_reply-test.c'; then $(CYGPATH_W) 'parse_reply-test.c'; else $(CYGPATH_W) '$(srcdir)/parse_reply-test.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/parse_reply_test-parse_reply-test.Tpo $(DEPDIR)/parse_reply_test-parse_reply-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='parse_reply-test.c' object='parse_reply_test-parse_reply-test.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -c -o parse_reply_test-parse_reply-test.obj `if test -f 'parse_reply-test.c'; then $(CYGPATH_W) 'parse_reply-test.c'; else $(CYGPATH_W) '$(srcdir)/parse_reply-test.c'; fi` - -parse_reply_test-resolve.o: resolve.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -MT parse_reply_test-resolve.o -MD -MP -MF $(DEPDIR)/parse_reply_test-resolve.Tpo -c -o parse_reply_test-resolve.o `test -f 'resolve.c' || echo '$(srcdir)/'`resolve.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/parse_reply_test-resolve.Tpo $(DEPDIR)/parse_reply_test-resolve.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='resolve.c' object='parse_reply_test-resolve.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -c -o parse_reply_test-resolve.o `test -f 'resolve.c' || echo '$(srcdir)/'`resolve.c - -parse_reply_test-resolve.obj: resolve.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -MT parse_reply_test-resolve.obj -MD -MP -MF $(DEPDIR)/parse_reply_test-resolve.Tpo -c -o parse_reply_test-resolve.obj `if test -f 'resolve.c'; then $(CYGPATH_W) 'resolve.c'; else $(CYGPATH_W) '$(srcdir)/resolve.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/parse_reply_test-resolve.Tpo $(DEPDIR)/parse_reply_test-resolve.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='resolve.c' object='parse_reply_test-resolve.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(parse_reply_test_CFLAGS) $(CFLAGS) -c -o parse_reply_test-resolve.obj `if test -f 'resolve.c'; then $(CYGPATH_W) 'resolve.c'; else $(CYGPATH_W) '$(srcdir)/resolve.c'; fi` - -snprintf_test-snprintf-test.o: snprintf-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -MT snprintf_test-snprintf-test.o -MD -MP -MF $(DEPDIR)/snprintf_test-snprintf-test.Tpo -c -o snprintf_test-snprintf-test.o `test -f 'snprintf-test.c' || echo '$(srcdir)/'`snprintf-test.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/snprintf_test-snprintf-test.Tpo $(DEPDIR)/snprintf_test-snprintf-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='snprintf-test.c' object='snprintf_test-snprintf-test.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf-test.o `test -f 'snprintf-test.c' || echo '$(srcdir)/'`snprintf-test.c - -snprintf_test-snprintf-test.obj: snprintf-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -MT snprintf_test-snprintf-test.obj -MD -MP -MF $(DEPDIR)/snprintf_test-snprintf-test.Tpo -c -o snprintf_test-snprintf-test.obj `if test -f 'snprintf-test.c'; then $(CYGPATH_W) 'snprintf-test.c'; else $(CYGPATH_W) '$(srcdir)/snprintf-test.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/snprintf_test-snprintf-test.Tpo $(DEPDIR)/snprintf_test-snprintf-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='snprintf-test.c' object='snprintf_test-snprintf-test.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf-test.obj `if test -f 'snprintf-test.c'; then $(CYGPATH_W) 'snprintf-test.c'; else $(CYGPATH_W) '$(srcdir)/snprintf-test.c'; fi` - -strpftime_test-strpftime-test.o: strpftime-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strpftime_test_CFLAGS) $(CFLAGS) -MT strpftime_test-strpftime-test.o -MD -MP -MF $(DEPDIR)/strpftime_test-strpftime-test.Tpo -c -o strpftime_test-strpftime-test.o `test -f 'strpftime-test.c' || echo '$(srcdir)/'`strpftime-test.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strpftime_test-strpftime-test.Tpo $(DEPDIR)/strpftime_test-strpftime-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strpftime-test.c' object='strpftime_test-strpftime-test.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strpftime_test_CFLAGS) $(CFLAGS) -c -o strpftime_test-strpftime-test.o `test -f 'strpftime-test.c' || echo '$(srcdir)/'`strpftime-test.c - -strpftime_test-strpftime-test.obj: strpftime-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strpftime_test_CFLAGS) $(CFLAGS) -MT strpftime_test-strpftime-test.obj -MD -MP -MF $(DEPDIR)/strpftime_test-strpftime-test.Tpo -c -o strpftime_test-strpftime-test.obj `if test -f 'strpftime-test.c'; then $(CYGPATH_W) 'strpftime-test.c'; else $(CYGPATH_W) '$(srcdir)/strpftime-test.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strpftime_test-strpftime-test.Tpo $(DEPDIR)/strpftime_test-strpftime-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='strpftime-test.c' object='strpftime_test-strpftime-test.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(strpftime_test_CFLAGS) $(CFLAGS) -c -o strpftime_test-strpftime-test.obj `if test -f 'strpftime-test.c'; then $(CYGPATH_W) 'strpftime-test.c'; else $(CYGPATH_W) '$(srcdir)/strpftime-test.c'; fi` - -tsearch_test-tsearch-test.o: tsearch-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tsearch_test_CFLAGS) $(CFLAGS) -MT tsearch_test-tsearch-test.o -MD -MP -MF $(DEPDIR)/tsearch_test-tsearch-test.Tpo -c -o tsearch_test-tsearch-test.o `test -f 'tsearch-test.c' || echo '$(srcdir)/'`tsearch-test.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tsearch_test-tsearch-test.Tpo $(DEPDIR)/tsearch_test-tsearch-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tsearch-test.c' object='tsearch_test-tsearch-test.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tsearch_test_CFLAGS) $(CFLAGS) -c -o tsearch_test-tsearch-test.o `test -f 'tsearch-test.c' || echo '$(srcdir)/'`tsearch-test.c - -tsearch_test-tsearch-test.obj: tsearch-test.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tsearch_test_CFLAGS) $(CFLAGS) -MT tsearch_test-tsearch-test.obj -MD -MP -MF $(DEPDIR)/tsearch_test-tsearch-test.Tpo -c -o tsearch_test-tsearch-test.obj `if test -f 'tsearch-test.c'; then $(CYGPATH_W) 'tsearch-test.c'; else $(CYGPATH_W) '$(srcdir)/tsearch-test.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tsearch_test-tsearch-test.Tpo $(DEPDIR)/tsearch_test-tsearch-test.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tsearch-test.c' object='tsearch_test-tsearch-test.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tsearch_test_CFLAGS) $(CFLAGS) -c -o tsearch_test-tsearch-test.obj `if test -f 'tsearch-test.c'; then $(CYGPATH_W) 'tsearch-test.c'; else $(CYGPATH_W) '$(srcdir)/tsearch-test.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-man3: $(man_MANS) - @$(NORMAL_INSTALL) - @list1=''; \ - list2='$(man_MANS)'; \ - test -n "$(man3dir)" \ - && test -n "`echo $$list1$$list2`" \ - || exit 0; \ - echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ - { for i in $$list1; do echo "$$i"; done; \ - if test -n "$$list2"; then \ - for i in $$list2; do echo "$$i"; done \ - | sed -n '/\.3[a-z]*$$/p'; \ - fi; \ - } | while read p; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; echo "$$p"; \ - done | \ - sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ - sed 'N;N;s,\n, ,g' | { \ - list=; while read file base inst; do \ - if test "$$base" = "$$inst"; then list="$$list $$file"; else \ - echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \ - $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \ - fi; \ - done; \ - for i in $$list; do echo "$$i"; done | $(am__base_list) | \ - while read files; do \ - test -z "$$files" || { \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \ - done; } - -uninstall-man3: - @$(NORMAL_UNINSTALL) - @list=''; test -n "$(man3dir)" || exit 0; \ - files=`{ for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.3[a-z]*$$/p'; \ - } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) -install-dist_includeHEADERS: $(dist_include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(dist_include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ - done - -uninstall-dist_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(dist_include_HEADERS)'; test -n "$(includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) -install-nodist_includeHEADERS: $(nodist_include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ - done - -uninstall-nodist_includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) -install-nodist_rokenincludeHEADERS: $(nodist_rokeninclude_HEADERS) - @$(NORMAL_INSTALL) - @list='$(nodist_rokeninclude_HEADERS)'; test -n "$(rokenincludedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(rokenincludedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(rokenincludedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(rokenincludedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(rokenincludedir)" || exit $$?; \ - done - -uninstall-nodist_rokenincludeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(nodist_rokeninclude_HEADERS)'; test -n "$(rokenincludedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(rokenincludedir)'; $(am__uninstall_files_from_dir) - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: $(check_PROGRAMS) - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -base64-test.log: base64-test$(EXEEXT) - @p='base64-test$(EXEEXT)'; \ - b='base64-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -getaddrinfo-test.log: getaddrinfo-test$(EXEEXT) - @p='getaddrinfo-test$(EXEEXT)'; \ - b='getaddrinfo-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -getifaddrs-test.log: getifaddrs-test$(EXEEXT) - @p='getifaddrs-test$(EXEEXT)'; \ - b='getifaddrs-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -getxxyyy-test.log: getxxyyy-test$(EXEEXT) - @p='getxxyyy-test$(EXEEXT)'; \ - b='getxxyyy-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -hex-test.log: hex-test$(EXEEXT) - @p='hex-test$(EXEEXT)'; \ - b='hex-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -test-readenv.log: test-readenv$(EXEEXT) - @p='test-readenv$(EXEEXT)'; \ - b='test-readenv'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -resolve-test.log: resolve-test$(EXEEXT) - @p='resolve-test$(EXEEXT)'; \ - b='resolve-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -parse_bytes-test.log: parse_bytes-test$(EXEEXT) - @p='parse_bytes-test$(EXEEXT)'; \ - b='parse_bytes-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -parse_reply-test.log: parse_reply-test$(EXEEXT) - @p='parse_reply-test$(EXEEXT)'; \ - b='parse_reply-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -parse_time-test.log: parse_time-test$(EXEEXT) - @p='parse_time-test$(EXEEXT)'; \ - b='parse_time-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -snprintf-test.log: snprintf-test$(EXEEXT) - @p='snprintf-test$(EXEEXT)'; \ - b='snprintf-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -strpftime-test.log: strpftime-test$(EXEEXT) - @p='strpftime-test$(EXEEXT)'; \ - b='strpftime-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -tsearch-test.log: tsearch-test$(EXEEXT) - @p='tsearch-test$(EXEEXT)'; \ - b='tsearch-test'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am -all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(MANS) $(HEADERS) \ - all-local -install-checkPROGRAMS: install-libLTLIBRARIES - -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(rokenincludedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ - clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -f $(DEPDIR)/chown.Plo - -rm -f $(DEPDIR)/closefrom.Plo - -rm -f $(DEPDIR)/copyhostent.Plo - -rm -f $(DEPDIR)/daemon.Plo - -rm -f $(DEPDIR)/ecalloc.Plo - -rm -f $(DEPDIR)/emalloc.Plo - -rm -f $(DEPDIR)/erealloc.Plo - -rm -f $(DEPDIR)/err.Plo - -rm -f $(DEPDIR)/errx.Plo - -rm -f $(DEPDIR)/estrdup.Plo - -rm -f $(DEPDIR)/fchown.Plo - -rm -f $(DEPDIR)/flock.Plo - -rm -f $(DEPDIR)/fnmatch.Plo - -rm -f $(DEPDIR)/freeaddrinfo.Plo - -rm -f $(DEPDIR)/freehostent.Plo - -rm -f $(DEPDIR)/gai_strerror.Plo - -rm -f $(DEPDIR)/getaddrinfo.Plo - -rm -f $(DEPDIR)/getcap.Plo - -rm -f $(DEPDIR)/getcwd.Plo - -rm -f $(DEPDIR)/getdtablesize.Plo - -rm -f $(DEPDIR)/getegid.Plo - -rm -f $(DEPDIR)/geteuid.Plo - -rm -f $(DEPDIR)/getgid.Plo - -rm -f $(DEPDIR)/gethostname.Plo - -rm -f $(DEPDIR)/getifaddrs.Plo - -rm -f $(DEPDIR)/getipnodebyaddr.Plo - -rm -f $(DEPDIR)/getipnodebyname.Plo - -rm -f $(DEPDIR)/getnameinfo.Plo - -rm -f $(DEPDIR)/getopt.Plo - -rm -f $(DEPDIR)/gettimeofday.Plo - -rm -f $(DEPDIR)/getuid.Plo - -rm -f $(DEPDIR)/getusershell.Plo - -rm -f $(DEPDIR)/glob.Plo - -rm -f $(DEPDIR)/hstrerror.Plo - -rm -f $(DEPDIR)/inet_aton.Plo - -rm -f $(DEPDIR)/inet_ntop.Plo - -rm -f $(DEPDIR)/inet_pton.Plo - -rm -f $(DEPDIR)/initgroups.Plo - -rm -f $(DEPDIR)/innetgr.Plo - -rm -f $(DEPDIR)/iruserok.Plo - -rm -f $(DEPDIR)/localtime_r.Plo - -rm -f $(DEPDIR)/lstat.Plo - -rm -f $(DEPDIR)/memmove.Plo - -rm -f $(DEPDIR)/memset_s.Plo - -rm -f $(DEPDIR)/mkstemp.Plo - -rm -f $(DEPDIR)/putenv.Plo - -rm -f $(DEPDIR)/rcmd.Plo - -rm -f $(DEPDIR)/readv.Plo - -rm -f $(DEPDIR)/recvmsg.Plo - -rm -f $(DEPDIR)/sendmsg.Plo - -rm -f $(DEPDIR)/setegid.Plo - -rm -f $(DEPDIR)/setenv.Plo - -rm -f $(DEPDIR)/seteuid.Plo - -rm -f $(DEPDIR)/strcasecmp.Plo - -rm -f $(DEPDIR)/strdup.Plo - -rm -f $(DEPDIR)/strerror.Plo - -rm -f $(DEPDIR)/strftime.Plo - -rm -f $(DEPDIR)/strlcat.Plo - -rm -f $(DEPDIR)/strlcpy.Plo - -rm -f $(DEPDIR)/strlwr.Plo - -rm -f $(DEPDIR)/strncasecmp.Plo - -rm -f $(DEPDIR)/strndup.Plo - -rm -f $(DEPDIR)/strnlen.Plo - -rm -f $(DEPDIR)/strptime.Plo - -rm -f $(DEPDIR)/strsep.Plo - -rm -f $(DEPDIR)/strsep_copy.Plo - -rm -f $(DEPDIR)/strtok_r.Plo - -rm -f $(DEPDIR)/strtoll.Plo - -rm -f $(DEPDIR)/strtoull.Plo - -rm -f $(DEPDIR)/strupr.Plo - -rm -f $(DEPDIR)/swab.Plo - -rm -f $(DEPDIR)/timegm.Plo - -rm -f $(DEPDIR)/tsearch.Plo - -rm -f $(DEPDIR)/unsetenv.Plo - -rm -f $(DEPDIR)/verr.Plo - -rm -f $(DEPDIR)/verrx.Plo - -rm -f $(DEPDIR)/vsyslog.Plo - -rm -f $(DEPDIR)/vwarn.Plo - -rm -f $(DEPDIR)/vwarnx.Plo - -rm -f $(DEPDIR)/warn.Plo - -rm -f $(DEPDIR)/warnx.Plo - -rm -f $(DEPDIR)/writev.Plo - -rm -f ./$(DEPDIR)/base64-test.Po - -rm -f ./$(DEPDIR)/getaddrinfo-test.Po - -rm -f ./$(DEPDIR)/getifaddrs-test.Po - -rm -f ./$(DEPDIR)/getxxyyy_test-getxxyyy.Po - -rm -f ./$(DEPDIR)/hex-test.Po - -rm -f ./$(DEPDIR)/libroken_la-base64.Plo - -rm -f ./$(DEPDIR)/libroken_la-bswap.Plo - -rm -f ./$(DEPDIR)/libroken_la-cloexec.Plo - -rm -f ./$(DEPDIR)/libroken_la-concat.Plo - -rm -f ./$(DEPDIR)/libroken_la-ct.Plo - -rm -f ./$(DEPDIR)/libroken_la-detach.Plo - -rm -f ./$(DEPDIR)/libroken_la-doxygen.Plo - -rm -f ./$(DEPDIR)/libroken_la-dumpdata.Plo - -rm -f ./$(DEPDIR)/libroken_la-environment.Plo - -rm -f ./$(DEPDIR)/libroken_la-eread.Plo - -rm -f ./$(DEPDIR)/libroken_la-esetenv.Plo - -rm -f ./$(DEPDIR)/libroken_la-ewrite.Plo - -rm -f ./$(DEPDIR)/libroken_la-get_default_username.Plo - -rm -f ./$(DEPDIR)/libroken_la-get_window_size.Plo - -rm -f ./$(DEPDIR)/libroken_la-getaddrinfo_hostspec.Plo - -rm -f ./$(DEPDIR)/libroken_la-getarg.Plo - -rm -f ./$(DEPDIR)/libroken_la-getnameinfo_verified.Plo - -rm -f ./$(DEPDIR)/libroken_la-getprogname.Plo - -rm -f ./$(DEPDIR)/libroken_la-getxxyyy.Plo - -rm -f ./$(DEPDIR)/libroken_la-h_errno.Plo - -rm -f ./$(DEPDIR)/libroken_la-hex.Plo - -rm -f ./$(DEPDIR)/libroken_la-hostent_find_fqdn.Plo - -rm -f ./$(DEPDIR)/libroken_la-issuid.Plo - -rm -f ./$(DEPDIR)/libroken_la-k_getpwnam.Plo - -rm -f ./$(DEPDIR)/libroken_la-k_getpwuid.Plo - -rm -f ./$(DEPDIR)/libroken_la-mini_inetd.Plo - -rm -f ./$(DEPDIR)/libroken_la-mkdir.Plo - -rm -f ./$(DEPDIR)/libroken_la-net_read.Plo - -rm -f ./$(DEPDIR)/libroken_la-net_write.Plo - -rm -f ./$(DEPDIR)/libroken_la-parse_bytes.Plo - -rm -f ./$(DEPDIR)/libroken_la-parse_time.Plo - -rm -f ./$(DEPDIR)/libroken_la-parse_units.Plo - -rm -f ./$(DEPDIR)/libroken_la-qsort.Plo - -rm -f ./$(DEPDIR)/libroken_la-rand.Plo - -rm -f ./$(DEPDIR)/libroken_la-realloc.Plo - -rm -f ./$(DEPDIR)/libroken_la-resolve.Plo - -rm -f ./$(DEPDIR)/libroken_la-roken_gethostby.Plo - -rm -f ./$(DEPDIR)/libroken_la-rtbl.Plo - -rm -f ./$(DEPDIR)/libroken_la-setprogname.Plo - -rm -f ./$(DEPDIR)/libroken_la-signal.Plo - -rm -f ./$(DEPDIR)/libroken_la-simple_exec.Plo - -rm -f ./$(DEPDIR)/libroken_la-snprintf.Plo - -rm -f ./$(DEPDIR)/libroken_la-socket.Plo - -rm -f ./$(DEPDIR)/libroken_la-socket_wrapper.Plo - -rm -f ./$(DEPDIR)/libroken_la-strcollect.Plo - -rm -f ./$(DEPDIR)/libroken_la-strerror_r.Plo - -rm -f ./$(DEPDIR)/libroken_la-strpool.Plo - -rm -f ./$(DEPDIR)/libroken_la-timeval.Plo - -rm -f ./$(DEPDIR)/libroken_la-tm2time.Plo - -rm -f ./$(DEPDIR)/libroken_la-unvis.Plo - -rm -f ./$(DEPDIR)/libroken_la-verify.Plo - -rm -f ./$(DEPDIR)/libroken_la-vis.Plo - -rm -f ./$(DEPDIR)/libroken_la-warnerr.Plo - -rm -f ./$(DEPDIR)/libroken_la-write_pid.Plo - -rm -f ./$(DEPDIR)/libroken_la-xfree.Plo - -rm -f ./$(DEPDIR)/libtest_la-snprintf.Plo - -rm -f ./$(DEPDIR)/libtest_la-strftime.Plo - -rm -f ./$(DEPDIR)/libtest_la-strptime.Plo - -rm -f ./$(DEPDIR)/libtest_la-tsearch.Plo - -rm -f ./$(DEPDIR)/make-roken.Po - -rm -f ./$(DEPDIR)/parse_bytes-test.Po - -rm -f ./$(DEPDIR)/parse_reply_test-parse_reply-test.Po - -rm -f ./$(DEPDIR)/parse_reply_test-resolve.Po - -rm -f ./$(DEPDIR)/parse_time-test.Po - -rm -f ./$(DEPDIR)/resolve-test.Po - -rm -f ./$(DEPDIR)/rkpty.Po - -rm -f ./$(DEPDIR)/snprintf_test-snprintf-test.Po - -rm -f ./$(DEPDIR)/strpftime_test-strpftime-test.Po - -rm -f ./$(DEPDIR)/test-detach.Po - -rm -f ./$(DEPDIR)/test-mem.Po - -rm -f ./$(DEPDIR)/test-readenv.Po - -rm -f ./$(DEPDIR)/tsearch_test-tsearch-test.Po - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-dist_includeHEADERS install-man \ - install-nodist_includeHEADERS \ - install-nodist_rokenincludeHEADERS - @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) install-data-hook -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-exec-local install-libLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: install-man3 - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f $(DEPDIR)/chown.Plo - -rm -f $(DEPDIR)/closefrom.Plo - -rm -f $(DEPDIR)/copyhostent.Plo - -rm -f $(DEPDIR)/daemon.Plo - -rm -f $(DEPDIR)/ecalloc.Plo - -rm -f $(DEPDIR)/emalloc.Plo - -rm -f $(DEPDIR)/erealloc.Plo - -rm -f $(DEPDIR)/err.Plo - -rm -f $(DEPDIR)/errx.Plo - -rm -f $(DEPDIR)/estrdup.Plo - -rm -f $(DEPDIR)/fchown.Plo - -rm -f $(DEPDIR)/flock.Plo - -rm -f $(DEPDIR)/fnmatch.Plo - -rm -f $(DEPDIR)/freeaddrinfo.Plo - -rm -f $(DEPDIR)/freehostent.Plo - -rm -f $(DEPDIR)/gai_strerror.Plo - -rm -f $(DEPDIR)/getaddrinfo.Plo - -rm -f $(DEPDIR)/getcap.Plo - -rm -f $(DEPDIR)/getcwd.Plo - -rm -f $(DEPDIR)/getdtablesize.Plo - -rm -f $(DEPDIR)/getegid.Plo - -rm -f $(DEPDIR)/geteuid.Plo - -rm -f $(DEPDIR)/getgid.Plo - -rm -f $(DEPDIR)/gethostname.Plo - -rm -f $(DEPDIR)/getifaddrs.Plo - -rm -f $(DEPDIR)/getipnodebyaddr.Plo - -rm -f $(DEPDIR)/getipnodebyname.Plo - -rm -f $(DEPDIR)/getnameinfo.Plo - -rm -f $(DEPDIR)/getopt.Plo - -rm -f $(DEPDIR)/gettimeofday.Plo - -rm -f $(DEPDIR)/getuid.Plo - -rm -f $(DEPDIR)/getusershell.Plo - -rm -f $(DEPDIR)/glob.Plo - -rm -f $(DEPDIR)/hstrerror.Plo - -rm -f $(DEPDIR)/inet_aton.Plo - -rm -f $(DEPDIR)/inet_ntop.Plo - -rm -f $(DEPDIR)/inet_pton.Plo - -rm -f $(DEPDIR)/initgroups.Plo - -rm -f $(DEPDIR)/innetgr.Plo - -rm -f $(DEPDIR)/iruserok.Plo - -rm -f $(DEPDIR)/localtime_r.Plo - -rm -f $(DEPDIR)/lstat.Plo - -rm -f $(DEPDIR)/memmove.Plo - -rm -f $(DEPDIR)/memset_s.Plo - -rm -f $(DEPDIR)/mkstemp.Plo - -rm -f $(DEPDIR)/putenv.Plo - -rm -f $(DEPDIR)/rcmd.Plo - -rm -f $(DEPDIR)/readv.Plo - -rm -f $(DEPDIR)/recvmsg.Plo - -rm -f $(DEPDIR)/sendmsg.Plo - -rm -f $(DEPDIR)/setegid.Plo - -rm -f $(DEPDIR)/setenv.Plo - -rm -f $(DEPDIR)/seteuid.Plo - -rm -f $(DEPDIR)/strcasecmp.Plo - -rm -f $(DEPDIR)/strdup.Plo - -rm -f $(DEPDIR)/strerror.Plo - -rm -f $(DEPDIR)/strftime.Plo - -rm -f $(DEPDIR)/strlcat.Plo - -rm -f $(DEPDIR)/strlcpy.Plo - -rm -f $(DEPDIR)/strlwr.Plo - -rm -f $(DEPDIR)/strncasecmp.Plo - -rm -f $(DEPDIR)/strndup.Plo - -rm -f $(DEPDIR)/strnlen.Plo - -rm -f $(DEPDIR)/strptime.Plo - -rm -f $(DEPDIR)/strsep.Plo - -rm -f $(DEPDIR)/strsep_copy.Plo - -rm -f $(DEPDIR)/strtok_r.Plo - -rm -f $(DEPDIR)/strtoll.Plo - -rm -f $(DEPDIR)/strtoull.Plo - -rm -f $(DEPDIR)/strupr.Plo - -rm -f $(DEPDIR)/swab.Plo - -rm -f $(DEPDIR)/timegm.Plo - -rm -f $(DEPDIR)/tsearch.Plo - -rm -f $(DEPDIR)/unsetenv.Plo - -rm -f $(DEPDIR)/verr.Plo - -rm -f $(DEPDIR)/verrx.Plo - -rm -f $(DEPDIR)/vsyslog.Plo - -rm -f $(DEPDIR)/vwarn.Plo - -rm -f $(DEPDIR)/vwarnx.Plo - -rm -f $(DEPDIR)/warn.Plo - -rm -f $(DEPDIR)/warnx.Plo - -rm -f $(DEPDIR)/writev.Plo - -rm -f ./$(DEPDIR)/base64-test.Po - -rm -f ./$(DEPDIR)/getaddrinfo-test.Po - -rm -f ./$(DEPDIR)/getifaddrs-test.Po - -rm -f ./$(DEPDIR)/getxxyyy_test-getxxyyy.Po - -rm -f ./$(DEPDIR)/hex-test.Po - -rm -f ./$(DEPDIR)/libroken_la-base64.Plo - -rm -f ./$(DEPDIR)/libroken_la-bswap.Plo - -rm -f ./$(DEPDIR)/libroken_la-cloexec.Plo - -rm -f ./$(DEPDIR)/libroken_la-concat.Plo - -rm -f ./$(DEPDIR)/libroken_la-ct.Plo - -rm -f ./$(DEPDIR)/libroken_la-detach.Plo - -rm -f ./$(DEPDIR)/libroken_la-doxygen.Plo - -rm -f ./$(DEPDIR)/libroken_la-dumpdata.Plo - -rm -f ./$(DEPDIR)/libroken_la-environment.Plo - -rm -f ./$(DEPDIR)/libroken_la-eread.Plo - -rm -f ./$(DEPDIR)/libroken_la-esetenv.Plo - -rm -f ./$(DEPDIR)/libroken_la-ewrite.Plo - -rm -f ./$(DEPDIR)/libroken_la-get_default_username.Plo - -rm -f ./$(DEPDIR)/libroken_la-get_window_size.Plo - -rm -f ./$(DEPDIR)/libroken_la-getaddrinfo_hostspec.Plo - -rm -f ./$(DEPDIR)/libroken_la-getarg.Plo - -rm -f ./$(DEPDIR)/libroken_la-getnameinfo_verified.Plo - -rm -f ./$(DEPDIR)/libroken_la-getprogname.Plo - -rm -f ./$(DEPDIR)/libroken_la-getxxyyy.Plo - -rm -f ./$(DEPDIR)/libroken_la-h_errno.Plo - -rm -f ./$(DEPDIR)/libroken_la-hex.Plo - -rm -f ./$(DEPDIR)/libroken_la-hostent_find_fqdn.Plo - -rm -f ./$(DEPDIR)/libroken_la-issuid.Plo - -rm -f ./$(DEPDIR)/libroken_la-k_getpwnam.Plo - -rm -f ./$(DEPDIR)/libroken_la-k_getpwuid.Plo - -rm -f ./$(DEPDIR)/libroken_la-mini_inetd.Plo - -rm -f ./$(DEPDIR)/libroken_la-mkdir.Plo - -rm -f ./$(DEPDIR)/libroken_la-net_read.Plo - -rm -f ./$(DEPDIR)/libroken_la-net_write.Plo - -rm -f ./$(DEPDIR)/libroken_la-parse_bytes.Plo - -rm -f ./$(DEPDIR)/libroken_la-parse_time.Plo - -rm -f ./$(DEPDIR)/libroken_la-parse_units.Plo - -rm -f ./$(DEPDIR)/libroken_la-qsort.Plo - -rm -f ./$(DEPDIR)/libroken_la-rand.Plo - -rm -f ./$(DEPDIR)/libroken_la-realloc.Plo - -rm -f ./$(DEPDIR)/libroken_la-resolve.Plo - -rm -f ./$(DEPDIR)/libroken_la-roken_gethostby.Plo - -rm -f ./$(DEPDIR)/libroken_la-rtbl.Plo - -rm -f ./$(DEPDIR)/libroken_la-setprogname.Plo - -rm -f ./$(DEPDIR)/libroken_la-signal.Plo - -rm -f ./$(DEPDIR)/libroken_la-simple_exec.Plo - -rm -f ./$(DEPDIR)/libroken_la-snprintf.Plo - -rm -f ./$(DEPDIR)/libroken_la-socket.Plo - -rm -f ./$(DEPDIR)/libroken_la-socket_wrapper.Plo - -rm -f ./$(DEPDIR)/libroken_la-strcollect.Plo - -rm -f ./$(DEPDIR)/libroken_la-strerror_r.Plo - -rm -f ./$(DEPDIR)/libroken_la-strpool.Plo - -rm -f ./$(DEPDIR)/libroken_la-timeval.Plo - -rm -f ./$(DEPDIR)/libroken_la-tm2time.Plo - -rm -f ./$(DEPDIR)/libroken_la-unvis.Plo - -rm -f ./$(DEPDIR)/libroken_la-verify.Plo - -rm -f ./$(DEPDIR)/libroken_la-vis.Plo - -rm -f ./$(DEPDIR)/libroken_la-warnerr.Plo - -rm -f ./$(DEPDIR)/libroken_la-write_pid.Plo - -rm -f ./$(DEPDIR)/libroken_la-xfree.Plo - -rm -f ./$(DEPDIR)/libtest_la-snprintf.Plo - -rm -f ./$(DEPDIR)/libtest_la-strftime.Plo - -rm -f ./$(DEPDIR)/libtest_la-strptime.Plo - -rm -f ./$(DEPDIR)/libtest_la-tsearch.Plo - -rm -f ./$(DEPDIR)/make-roken.Po - -rm -f ./$(DEPDIR)/parse_bytes-test.Po - -rm -f ./$(DEPDIR)/parse_reply_test-parse_reply-test.Po - -rm -f ./$(DEPDIR)/parse_reply_test-resolve.Po - -rm -f ./$(DEPDIR)/parse_time-test.Po - -rm -f ./$(DEPDIR)/resolve-test.Po - -rm -f ./$(DEPDIR)/rkpty.Po - -rm -f ./$(DEPDIR)/snprintf_test-snprintf-test.Po - -rm -f ./$(DEPDIR)/strpftime_test-strpftime-test.Po - -rm -f ./$(DEPDIR)/test-detach.Po - -rm -f ./$(DEPDIR)/test-mem.Po - -rm -f ./$(DEPDIR)/test-readenv.Po - -rm -f ./$(DEPDIR)/tsearch_test-tsearch-test.Po - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-dist_includeHEADERS uninstall-libLTLIBRARIES \ - uninstall-man uninstall-nodist_includeHEADERS \ - uninstall-nodist_rokenincludeHEADERS - @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) uninstall-hook -uninstall-man: uninstall-man3 - -.MAKE: all check check-am install install-am install-data-am \ - install-exec install-strip uninstall-am - -.PHONY: CTAGS GTAGS TAGS all all-am all-local am--depfiles check \ - check-TESTS check-am check-local clean clean-checkPROGRAMS \ - clean-generic clean-libLTLIBRARIES clean-libtool \ - clean-noinstLTLIBRARIES clean-noinstPROGRAMS cscopelist-am \ - ctags ctags-am dist-hook distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-data-hook \ - install-dist_includeHEADERS install-dvi install-dvi-am \ - install-exec install-exec-am install-exec-local install-html \ - install-html-am install-info install-info-am \ - install-libLTLIBRARIES install-man install-man3 \ - install-nodist_includeHEADERS \ - install-nodist_rokenincludeHEADERS install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am \ - uninstall-dist_includeHEADERS uninstall-hook \ - uninstall-libLTLIBRARIES uninstall-man uninstall-man3 \ - uninstall-nodist_includeHEADERS \ - uninstall-nodist_rokenincludeHEADERS - -.PRECIOUS: Makefile - - -install-suid-programs: - @foo='$(bin_SUIDS)'; \ - for file in $$foo; do \ - x=$(DESTDIR)$(bindir)/$$file; \ - if chown 0:0 $$x && chmod u+s $$x; then :; else \ - echo "*"; \ - echo "* Failed to install $$x setuid root"; \ - echo "*"; \ - fi; \ - done - -install-exec-local: install-suid-programs - -codesign-all: - @if [ X"$$CODE_SIGN_IDENTITY" != X ] ; then \ - foo='$(bin_PROGRAMS) $(sbin_PROGRAMS) $(libexec_PROGRAMS)' ; \ - for file in $$foo ; do \ - echo "CODESIGN $$file" ; \ - codesign -f -s "$$CODE_SIGN_IDENTITY" $$file || exit 1 ; \ - done ; \ - fi - -all-local: codesign-all - -install-build-headers:: $(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(nobase_include_HEADERS) $(noinst_HEADERS) - @foo='$(include_HEADERS) $(dist_include_HEADERS) $(nodist_include_HEADERS) $(build_HEADERZ) $(noinst_HEADERS)'; \ - for f in $$foo; do \ - f=`basename $$f`; \ - if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \ - else file="$$f"; fi; \ - if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \ - : ; else \ - echo " $(CP) $$file $(buildinclude)/$$f"; \ - $(CP) $$file $(buildinclude)/$$f || true; \ - fi ; \ - done ; \ - foo='$(nobase_include_HEADERS)'; \ - for f in $$foo; do \ - if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \ - else file="$$f"; fi; \ - $(mkdir_p) $(buildinclude)/`dirname $$f` ; \ - if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \ - : ; else \ - echo " $(CP) $$file $(buildinclude)/$$f"; \ - $(CP) $$file $(buildinclude)/$$f; \ - fi ; \ - done - -all-local: install-build-headers - -check-local:: - @if test '$(CHECK_LOCAL)' = "no-check-local"; then \ - foo=''; elif test '$(CHECK_LOCAL)'; then \ - foo='$(CHECK_LOCAL)'; else \ - foo='$(PROGRAMS)'; fi; \ - if test "$$foo"; then \ - failed=0; all=0; \ - for i in $$foo; do \ - all=`expr $$all + 1`; \ - if (./$$i --version && ./$$i --help) > /dev/null 2>&1; then \ - echo "PASS: $$i"; \ - else \ - echo "FAIL: $$i"; \ - failed=`expr $$failed + 1`; \ - fi; \ - done; \ - if test "$$failed" -eq 0; then \ - banner="All $$all tests passed"; \ - else \ - banner="$$failed of $$all tests failed"; \ - fi; \ - dashes=`echo "$$banner" | sed s/./=/g`; \ - echo "$$dashes"; \ - echo "$$banner"; \ - echo "$$dashes"; \ - test "$$failed" -eq 0 || exit 1; \ - fi - -# It's useful for debugging to format generated sources. The default for all -# clang-format styles is to sort includes, but in many cases in-tree we really -# don't want to do that. -.x.c: - @if [ -z "$(CLANG_FORMAT)" ]; then \ - cmp -s $< $@ 2> /dev/null || cp $< $@; \ - else \ - cp $< $@.tmp.c; \ - $(CLANG_FORMAT) -style='{BasedOnStyle: Chromium, SortIncludes: false}' -i $@.tmp.c; \ - cmp -s $@.tmp.c $@ 2> /dev/null || mv $@.tmp.c $@; \ - fi - -.hx.h: - @cmp -s $< $@ 2> /dev/null || cp $< $@; -#NROFF_MAN = nroff -man -.1.cat1: - $(NROFF_MAN) $< > $@ -.3.cat3: - $(NROFF_MAN) $< > $@ -.5.cat5: - $(NROFF_MAN) $< > $@ -.7.cat7: - $(NROFF_MAN) $< > $@ -.8.cat8: - $(NROFF_MAN) $< > $@ - -dist-cat1-mans: - @foo='$(man1_MANS)'; \ - bar='$(man_MANS)'; \ - for i in $$bar; do \ - case $$i in \ - *.1) foo="$$foo $$i";; \ - esac; done ;\ - for i in $$foo; do \ - x=`echo $$i | sed 's/\.[^.]*$$/.cat1/'`; \ - echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ - $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ - done - -dist-cat3-mans: - @foo='$(man3_MANS)'; \ - bar='$(man_MANS)'; \ - for i in $$bar; do \ - case $$i in \ - *.3) foo="$$foo $$i";; \ - esac; done ;\ - for i in $$foo; do \ - x=`echo $$i | sed 's/\.[^.]*$$/.cat3/'`; \ - echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ - $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ - done - -dist-cat5-mans: - @foo='$(man5_MANS)'; \ - bar='$(man_MANS)'; \ - for i in $$bar; do \ - case $$i in \ - *.5) foo="$$foo $$i";; \ - esac; done ;\ - for i in $$foo; do \ - x=`echo $$i | sed 's/\.[^.]*$$/.cat5/'`; \ - echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ - $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ - done - -dist-cat7-mans: - @foo='$(man7_MANS)'; \ - bar='$(man_MANS)'; \ - for i in $$bar; do \ - case $$i in \ - *.7) foo="$$foo $$i";; \ - esac; done ;\ - for i in $$foo; do \ - x=`echo $$i | sed 's/\.[^.]*$$/.cat7/'`; \ - echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ - $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ - done - -dist-cat8-mans: - @foo='$(man8_MANS)'; \ - bar='$(man_MANS)'; \ - for i in $$bar; do \ - case $$i in \ - *.8) foo="$$foo $$i";; \ - esac; done ;\ - for i in $$foo; do \ - x=`echo $$i | sed 's/\.[^.]*$$/.cat8/'`; \ - echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ - $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ - done - -dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat7-mans dist-cat8-mans - -install-cat-mans: - $(SHELL) $(top_srcdir)/cf/install-catman.sh install "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man7_MANS) $(man8_MANS) - -uninstall-cat-mans: - $(SHELL) $(top_srcdir)/cf/install-catman.sh uninstall "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man7_MANS) $(man8_MANS) - -install-data-hook: install-cat-mans -uninstall-hook: uninstall-cat-mans - -.et.h: - $(COMPILE_ET) $< -.et.c: - $(COMPILE_ET) $< - -# -# Useful target for debugging -# - -check-valgrind: - tobjdir=`cd $(top_builddir) && pwd` ; \ - tsrcdir=`cd $(top_srcdir) && pwd` ; \ - env TESTS_ENVIRONMENT="$${tsrcdir}/cf/maybe-valgrind.sh -s $${tsrcdir} -o $${tobjdir}" make check - -# -# Target to please samba build farm, builds distfiles in-tree. -# Will break when automake changes... -# - -distdir-in-tree: $(DISTFILES) $(INFO_DEPS) - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" != .; then \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) distdir-in-tree) ; \ - fi ; \ - done - -$(LTLIBOBJS) $(libroken_la_OBJECTS): roken.h $(XHEADERS) -.hin.h: - cp $< $@ - -@CROSS_COMPILE_FALSE@roken.h: make-roken$(EXEEXT) -@CROSS_COMPILE_FALSE@ @./make-roken$(EXEEXT) > tmp.h ;\ -@CROSS_COMPILE_FALSE@ if [ -f roken.h ] && cmp -s tmp.h roken.h ; then rm -f tmp.h ; \ -@CROSS_COMPILE_FALSE@ else rm -f roken.h; mv tmp.h roken.h; fi - -@CROSS_COMPILE_FALSE@make-roken.c: roken.h.in roken.awk -@CROSS_COMPILE_FALSE@ $(AWK) -f $(srcdir)/roken.awk $(srcdir)/roken.h.in > make-roken.c - -@CROSS_COMPILE_TRUE@roken.h: $(top_srcdir)/cf/roken-h-process.pl roken.h.in -@CROSS_COMPILE_TRUE@ perl $(top_srcdir)/cf/roken-h-process.pl \ -@CROSS_COMPILE_TRUE@ -c $(top_builddir)/include/config.h \ -@CROSS_COMPILE_TRUE@ -p $(srcdir)/roken.h.in -o roken.h - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/lib/roken/NTMakefile b/lib/roken/NTMakefile index 57ef7506f81f..5749efd5cc92 100644 --- a/lib/roken/NTMakefile +++ b/lib/roken/NTMakefile @@ -1,6 +1,6 @@ ######################################################################## # -# Copyright (c) 2009, Secure Endpoints Inc. +# Copyright (c) 2009 - 2017, Secure Endpoints Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -34,10 +34,12 @@ RELDIR=lib\roken !include ../../windows/NTMakefile.w32 libroken_la_OBJS = \ + $(OBJ)\base32.obj \ $(OBJ)\base64.obj \ $(OBJ)\bswap.obj \ $(OBJ)\concat.obj \ $(OBJ)\cloexec.obj \ + $(OBJ)\clz.obj \ $(OBJ)\ct.obj \ $(OBJ)\detach.obj \ $(OBJ)\dirent.obj \ @@ -55,8 +57,10 @@ libroken_la_OBJS = \ $(OBJ)\ewrite.obj \ $(OBJ)\flock.obj \ $(OBJ)\fnmatch.obj \ + $(OBJ)\fseeko.obj \ + $(OBJ)\ftello.obj \ + $(OBJ)\getauxval.obj \ $(OBJ)\getaddrinfo_hostspec.obj \ - $(OBJ)\get_default_username.obj \ $(OBJ)\get_window_size.obj \ $(OBJ)\getarg.obj \ $(OBJ)\getifaddrs_w32.obj \ @@ -64,16 +68,21 @@ libroken_la_OBJS = \ $(OBJ)\getopt.obj \ $(OBJ)\getprogname.obj \ $(OBJ)\gettimeofday.obj \ + $(OBJ)\getuserinfo.obj \ $(OBJ)\hex.obj \ $(OBJ)\hostent_find_fqdn.obj \ $(OBJ)\inet_aton.obj \ $(OBJ)\issuid.obj \ $(OBJ)\localtime_r.obj \ $(OBJ)\lstat.obj \ + $(OBJ)\memmem.obj \ $(OBJ)\memset_s.obj \ + $(OBJ)\mergesort_r.obj \ $(OBJ)\mkdir.obj \ $(OBJ)\mini_inetd.obj \ + $(OBJ)\mkdtemp.obj \ $(OBJ)\mkstemp.obj \ + $(OBJ)\mkostemp.obj \ $(OBJ)\net_read.obj \ $(OBJ)\net_write.obj \ $(OBJ)\parse_bytes.obj \ @@ -85,6 +94,7 @@ libroken_la_OBJS = \ $(OBJ)\rand.obj \ $(OBJ)\roken_gethostby.obj \ $(OBJ)\rtbl.obj \ + $(OBJ)\secure_getenv.obj \ $(OBJ)\sendmsg.obj \ $(OBJ)\setenv.obj \ $(OBJ)\setprogname.obj \ @@ -95,6 +105,7 @@ libroken_la_OBJS = \ $(OBJ)\sockstartup_w32.obj \ $(OBJ)\strcollect.obj \ $(OBJ)\strerror_r.obj \ + $(OBJ)\strftime.obj \ $(OBJ)\strlcat.obj \ $(OBJ)\strlcpy.obj \ $(OBJ)\strndup.obj \ @@ -120,6 +131,7 @@ libroken_la_OBJS = \ $(OBJ)\warnerr.obj \ $(OBJ)\warnx.obj \ $(OBJ)\win32_alloc.obj \ + $(OBJ)\win32_version.obj \ $(OBJ)\writev.obj \ $(OBJ)\xfree.obj @@ -148,13 +160,13 @@ $(INCDIR)\roken.h: $(OBJ)\make-roken.exe $(OBJ)\make-roken.exe > $@ || $(RM) $@ INCFILES = \ + $(INCDIR)\base32.h \ $(INCDIR)\base64.h \ $(INCDIR)\dirent.h \ $(INCDIR)\dlfcn.h \ $(INCDIR)\err.h \ $(INCDIR)\fnmatch.h \ $(INCDIR)\getarg.h \ - $(INCDIR)\glob.h \ $(INCDIR)\hex.h \ $(INCDIR)\ifaddrs.h \ $(INCDIR)\parse_bytes.h \ @@ -168,9 +180,11 @@ INCFILES = \ $(INCDIR)\stdbool.h \ $(INCDIR)\syslog.h \ $(INCDIR)\vis.h \ + $(INCDIR)\vis-extras.h \ !ifndef HAVE_STDINT_H $(INCDIR)\stdint.h \ !endif + $(INCDIR)\versionsupport.h \ $(INCDIR)\xdbm.h clean:: @@ -181,16 +195,18 @@ all:: $(INCFILES) $(LIBROKEN) clean:: -$(RM) $(LIBROKEN) -TMP_PROGS = $(OBJ)\snprintf-test.exe $(OBJ)\resolve-test.exe +TMP_PROGS = $(OBJ)\snprintf-test.exe $(OBJ)\resolve-test.exe $(OBJ)\test-getuserinfo.exe # Tests TEST_PROGS = \ + $(OBJ)\base32-test.exe \ $(OBJ)\base64-test.exe \ $(OBJ)\getaddrinfo-test.exe \ $(OBJ)\getifaddrs-test.exe \ $(OBJ)\hex-test.exe \ $(OBJ)\test-detach.exe \ + $(OBJ)\test-getuserinfo.exe \ $(OBJ)\test-readenv.exe \ $(OBJ)\parse_bytes-test.exe \ $(OBJ)\parse_reply-test.exe \ @@ -242,6 +258,9 @@ $(OBJ)\snprintf-test.exe: $(OBJ)\snprintf-test.obj $(OBJ)\libtest.lib $(LIBROKEN $(OBJ)\resolve-test.exe: $(OBJ)\resolve-test.obj $(LIBROKEN) $(EXECONLINK) DnsAPI.lib +$(OBJ)\base32-test.exe: $(OBJ)\base32-test.obj $(OBJ)\base32.obj $(LIBROKEN) + $(EXECONLINK) + $(OBJ)\base64-test.exe: $(OBJ)\base64-test.obj $(OBJ)\base64.obj $(LIBROKEN) $(EXECONLINK) @@ -257,6 +276,9 @@ $(OBJ)\parse_bytes-test.exe: $(OBJ)\parse_bytes-test.obj $(LIBROKEN) $(OBJ)\test-detach.exe: $(OBJ)\test-detach.obj $(OBJ)\detach.obj $(LIBROKEN) $(EXECONLINK) +$(OBJ)\test-getuserinfo.exe: $(OBJ)\test-getuserinfo.obj $(OBJ)\getuserinfo.obj $(LIBROKEN) + $(EXECONLINK) Secur32.lib Shell32.lib + $(OBJ)\dirent-test.exe: $(OBJ)\dirent-test.obj $(LIBROKEN) $(EXECONLINK) @@ -272,8 +294,9 @@ test-run: cd $(OBJ) -test-mini_inetd.exe -dirent-test.exe + -base32-test.exe -base64-test.exe - -getaddrinfo-test.exe + -getaddrinfo-test.exe www.h5l.org http -getifaddrs-test.exe -hex-test.exe -test-readenv.exe diff --git a/lib/roken/base32-test.c b/lib/roken/base32-test.c new file mode 100644 index 000000000000..e30c193c478e --- /dev/null +++ b/lib/roken/base32-test.c @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include "roken.h" +#include <base32.h> + +int +main(int argc, char **argv) +{ + int numerr = 0; + int numtest = 1; + struct test { + int preserve_order; + void *data; + size_t len; + const char *result; + } *t, tests[] = { + { 0, "", 0 , "" }, + { 0, "f", 1, "MY======" }, + { 0, "fo", 2, "MZXQ====" }, + { 0, "foo", 3, "MZXW6===" }, + { 0, "foob", 4, "MZXW6YQ=" }, + { 0, "fooba", 5, "MZXW6YTB" }, + { 0, "foobar", 6, "MZXW6YTBOI======" }, + { 1, "", 0 , "" }, + { 1, "f", 1, "CO======" }, + { 1, "fo", 2, "CPNG====" }, + { 1, "foo", 3, "CPNMU===" }, + { 1, "foob", 4, "CPNMUOG=" }, + { 1, "fooba", 5, "CPNMUOJ1" }, + { 1, "foobar", 6, "CPNMUOJ1E8======" }, + { 0, NULL, 0, NULL } + }; + for(t = tests; t->data; t++) { + char *str; + int len; + + (void) rk_base32_encode(t->data, t->len, &str, t->preserve_order); + if (strcmp(str, t->result) != 0) { + fprintf(stderr, "failed test %d: %s != %s\n", numtest, + str, t->result); + numerr++; + } + free(str); + str = strdup(t->result); + len = rk_base32_decode(t->result, str, t->preserve_order); + if (len != t->len) { + fprintf(stderr, "failed test %d: len %lu != %lu\n", numtest, + (unsigned long)len, (unsigned long)t->len); + numerr++; + } else if(memcmp(str, t->data, t->len) != 0) { + fprintf(stderr, "failed test %d: data\n", numtest); + numerr++; + } + free(str); + numtest++; + } + + { + char str[32]; + + if (rk_base32_decode("M=M=", str, 1) != -1) { + fprintf(stderr, "failed test %d: successful decode of `M=M='\n", + numtest++); + numerr++; + } + if (rk_base32_decode("MQ===", str, 1) != -1) { + fprintf(stderr, "failed test %d: successful decode of `MQ==='\n", + numtest++); + numerr++; + } + } + return numerr; +} diff --git a/lib/roken/base32.c b/lib/roken/base32.c new file mode 100644 index 000000000000..1a2753216443 --- /dev/null +++ b/lib/roken/base32.c @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2020 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#ifdef TEST +#include <stdio.h> +#include <getarg.h> +#include <err.h> +#endif +#include "base32.h" +#include "roken.h" + +static const unsigned char base32_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; +static const unsigned char base32op_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV"; + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_base32_encode(const void *data, int size, char **str, enum rk_base32_flags flags) +{ + const unsigned char *chars = + (flags & RK_BASE32_FLAG_PRESERVE_ORDER) ? base32op_chars : + base32_chars; + uint64_t c; + char *s, *p; + int i; + const unsigned char *q; + + if (size > INT_MAX/8 || size < 0) { + *str = NULL; + errno = ERANGE; + return -1; + } + + p = s = malloc(((size + 5 - 1) / 5) * 8 + 1); + if (p == NULL) { + *str = NULL; + return -1; + } + q = (const unsigned char *) data; + + for (i = 0; i < size;) { + /* 5 bytes of input will give us 8 output bytes' worth of bits */ + c = q[i++]; + c <<= 8; + if (i < size) + c += q[i]; + i++; + c <<= 8; + if (i < size) + c += q[i]; + i++; + c <<= 8; + if (i < size) + c += q[i]; + i++; + c <<= 8; + if (i < size) + c += q[i]; + i++; + p[0] = chars[(c & 0x00000000f800000000ULL) >> 35]; + p[1] = chars[(c & 0x0000000007c0000000ULL) >> 30]; + p[2] = chars[(c & 0x00000000003e000000ULL) >> 25]; + p[3] = chars[(c & 0x000000000001f00000ULL) >> 20]; + p[4] = chars[(c & 0x0000000000000f8000ULL) >> 15]; + p[5] = chars[(c & 0x000000000000007c00ULL) >> 10]; + p[6] = chars[(c & 0x0000000000000003e0ULL) >> 5]; + p[7] = chars[(c & 0x00000000000000001fULL) >> 0]; + switch (i - size) { + case 4: p[2] = p[3] = '='; HEIM_FALLTHROUGH; + case 3: p[4] = '='; HEIM_FALLTHROUGH; + case 2: p[5] = p[6] = '='; HEIM_FALLTHROUGH; + case 1: p[7] = '='; HEIM_FALLTHROUGH; + default: break; + } + p += 8; + } + *p = 0; + *str = s; + return (int) strlen(s); +} + +#define DECODE_ERROR ((uint64_t)-1) + +static int +pos(char c, int preserve_order) +{ + /* EBCDIC need not apply */ + if (preserve_order) { + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'A' && c <= 'V') + return c - 'A' + ('9' - '0') + 1; + } else { + if (c >= 'A' && c <= 'Z') + return c - 'A'; + if (c >= '2' && c <= '7') + return c - '2' + ('Z' - 'A') + 1; + } + return -1; +} + +static uint64_t +token_decode(const char *token, enum rk_base32_flags flags) +{ + uint64_t marker = 0; + uint64_t val = 0; + int preserve_order = !!(flags & RK_BASE32_FLAG_PRESERVE_ORDER); + int i, c; + + for (i = 0; i < 8 && token[i] != '\0'; i++) { + val <<= 5; + if (token[i] == '=') + marker++; + else if (marker) + return DECODE_ERROR; + else if ((c = pos(token[i], preserve_order)) == -1 && + (flags & RK_BASE32_FLAG_STOP_ON_GARBAGE)) + break; + else if (c == -1) + return DECODE_ERROR; + else + val |= c; + } + if (i < 8 || marker > 6) + return DECODE_ERROR; + return (marker << 40) | val; +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_base32_decode(const char *str, void *data, enum rk_base32_flags flags) +{ + const char *p; + unsigned char *q; + int preserve_order = !!(flags & RK_BASE32_FLAG_PRESERVE_ORDER); + + q = data; + for (p = str; *p && (*p == '=' || pos(*p, preserve_order) != -1); p += 8) { + uint64_t val = token_decode(p, flags); + uint64_t marker = (val >> 40) & 0xffULL; + + if (val == DECODE_ERROR) { + errno = EINVAL; + return -1; + } + *q++ = (val >> 32) & 0xffULL; + if (marker < 6) + *q++ = (val >> 24) & 0xffULL; + if (marker < 4) + *q++ = (val >> 16) & 0xffULL; + if (marker < 3) + *q++ = (val >> 8) & 0xffULL; + if (marker < 1) + *q++ = val & 0xffULL; + if (marker && !(flags & RK_BASE32_FLAG_INTERIOR_PADDING_OK)) + break; + } + if (q - (unsigned char *) data > INT_MAX) { + errno = EOVERFLOW; + return -1; + } + return q - (unsigned char *) data; +} + +#ifdef TEST +static int interior_padding_ok; +static int preserve_order_flag; +static int stop_on_garbage; +static int decode_flag; +static int help_flag; + +/* + * The short options are compatible with a subset of the FreeBSD contrib + * vis(1). Heimdal additions have long option names only. + */ +static struct getargs args[] = { + { "preserve-order", 'P', arg_flag, &preserve_order_flag, + "Use order-preserving alphabet", NULL }, + { "interior-padding-ok", 'O', arg_flag, &interior_padding_ok, + "Decode concatenated padded base32 strings as one", NULL }, + { "stop-on-garbage", 'G', arg_flag, &stop_on_garbage, + "Do not error on garbage", NULL }, + { "decode", 'd', arg_flag, &decode_flag, "Decode", NULL }, + { "help", 'h', arg_flag, &help_flag, "Print help message", NULL }, +}; +static size_t num_args = sizeof(args)/sizeof(args[0]); + +int +main(int argc, char **argv) +{ + enum rk_base32_flags flags = 0; + unsigned char *buf = NULL; + size_t buflen = 0; + size_t bufsz = 0; + int goptind = 0; + int ret; + + setprogname("rkbase32"); + if (getarg(args, num_args, argc, argv, &goptind) || help_flag) { + arg_printusage(args, num_args, NULL, "FILE | -"); + return help_flag ? 0 : 1; + } + + argc -= goptind; + argv += goptind; + + flags |= preserve_order_flag ? RK_BASE32_FLAG_PRESERVE_ORDER : 0; + flags |= interior_padding_ok ? RK_BASE32_FLAG_INTERIOR_PADDING_OK : 0; + flags |= stop_on_garbage ? RK_BASE32_FLAG_STOP_ON_GARBAGE : 0; + + if (help_flag) + return arg_printusage(args, num_args, NULL, "FILE | -- -"), 0; + if (argc != 1) + return arg_printusage(args, num_args, NULL, "FILE | -- -"), 1; + + if (strcmp(argv[0], "-") == 0) { + unsigned char *tmp; + unsigned char d[4096]; + size_t bytes; + + while (!feof(stdin) && !ferror(stdin)) { + bytes = fread(d, 1, sizeof(d), stdin); + if (bytes == 0) + continue; + if (buflen + bytes > bufsz) { + if ((tmp = realloc(buf, bufsz + (bufsz >> 2) + sizeof(d))) == NULL) + err(1, "Could not read stdin"); + buf = tmp; + bufsz = bufsz + (bufsz >> 2) + sizeof(d); + } + memcpy(buf + buflen, d, bytes); + buflen += bytes; + } + if (ferror(stdin)) + err(1, "Could not read stdin"); + } else { + void *d; + + if ((errno = rk_undumpdata(argv[0], &d, &bufsz))) + err(1, "Could not read %s", argv[0]); + buflen = bufsz; + buf = d; + } + + if (decode_flag) { + unsigned char *d; + + if (buflen == bufsz) { + unsigned char *tmp; + + if ((tmp = realloc(buf, bufsz + 1)) == NULL) + err(1, "Could not decode data"); + buf = tmp; + bufsz++; + } + buf[buflen] = '\0'; + + if ((d = malloc(buflen * 5 / 8 + 4)) == NULL) + err(1, "Could not decode data"); + + if ((ret = rk_base32_decode((const char *)buf, d, flags)) < 0) + err(1, "Could not decode data"); + if (fwrite(d, ret, 1, stdout) != 1) + err(1, "Could not write decoded data"); + free(d); + } else if (buf) { /* buf can be NULL if we read from an empty file */ + char *e; + + if ((ret = rk_base32_encode(buf, buflen, &e, flags)) < 0) + err(1, "Could not encode data"); + if (fwrite(e, ret, 1, stdout) != 1) + err(1, "Could not write decoded data"); + free(e); + if (fwrite("\n", 1, 1, stdout) != 1) + err(1, "Could not write decoded data"); + } + free(buf); + return 0; +} +#endif diff --git a/lib/roken/base32.h b/lib/roken/base32.h new file mode 100644 index 000000000000..1dc0dd02bbb8 --- /dev/null +++ b/lib/roken/base32.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id$ */ + +#ifndef _BASE32_H_ +#define _BASE32_H_ + +#ifndef ROKEN_LIB_FUNCTION +#ifdef _WIN32 +#define ROKEN_LIB_FUNCTION +#define ROKEN_LIB_CALL __cdecl +#else +#define ROKEN_LIB_FUNCTION +#define ROKEN_LIB_CALL +#endif +#endif + +enum rk_base32_flags { + RK_BASE32_FLAG_PRESERVE_ORDER = 1, + RK_BASE32_FLAG_STOP_ON_GARBAGE = 2, + RK_BASE32_FLAG_INTERIOR_PADDING_OK = 4, +}; + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_base32_encode(const void *, int, char **, enum rk_base32_flags); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_base32_decode(const char *, void *, enum rk_base32_flags); + +#endif diff --git a/lib/roken/base64-test.c b/lib/roken/base64-test.c index 86cccbb1d4f9..8fb3f528001f 100644 --- a/lib/roken/base64-test.c +++ b/lib/roken/base64-test.c @@ -58,7 +58,8 @@ main(int argc, char **argv) for(t = tests; t->data; t++) { char *str; int len; - len = rk_base64_encode(t->data, t->len, &str); + + (void) rk_base64_encode(t->data, t->len, &str); if(strcmp(str, t->result) != 0) { fprintf(stderr, "failed test %d: %s != %s\n", numtest, str, t->result); diff --git a/lib/roken/base64.c b/lib/roken/base64.c index 6ee4899e5331..1391c8280797 100644 --- a/lib/roken/base64.c +++ b/lib/roken/base64.c @@ -33,22 +33,43 @@ #include <config.h> +#include <errno.h> #include <stdlib.h> #include <string.h> #include <limits.h> +#ifdef TEST +#include <stdio.h> +#include <getarg.h> +#include <err.h> +#endif #include "base64.h" +#include "roken.h" -static const char base64_chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +#define base64_chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" static int pos(char c) { +#if 'A' == '\301' const char *p; for (p = base64_chars; *p; p++) if (*p == c) return p - base64_chars; return -1; +#else + if (c >= 'A' && c <= 'Z') + return c - 'A'; + if (c >= 'a' && c <= 'z') + return ('Z' + 1 - 'A') + c - 'a'; + if (c >= '0' && c <= '9') + return ('Z' + 1 - 'A') + + ('z' + 1 - 'a') + c - '0'; + if (c == '+') + return 62; + if (c == '/') + return 63; + return -1; +#endif } ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL @@ -61,6 +82,7 @@ rk_base64_encode(const void *data, int size, char **str) if (size > INT_MAX/4 || size < 0) { *str = NULL; + errno = ERANGE; return -1; } @@ -104,9 +126,7 @@ token_decode(const char *token) int i; unsigned int val = 0; int marker = 0; - if (strlen(token) < 4) - return DECODE_ERROR; - for (i = 0; i < 4; i++) { + for (i = 0; i < 4 && token[i] != '\0'; i++) { val *= 64; if (token[i] == '=') marker++; @@ -115,7 +135,7 @@ token_decode(const char *token) else val += pos(token[i]); } - if (marker > 2) + if (i < 4 || marker > 2) return DECODE_ERROR; return (marker << 24) | val; } @@ -127,16 +147,124 @@ rk_base64_decode(const char *str, void *data) unsigned char *q; q = data; - for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) { + for (p = str; *p && (*p == '=' || pos(*p) != -1); p += 4) { unsigned int val = token_decode(p); unsigned int marker = (val >> 24) & 0xff; - if (val == DECODE_ERROR) + if (val == DECODE_ERROR) { + errno = EINVAL; return -1; + } *q++ = (val >> 16) & 0xff; if (marker < 2) *q++ = (val >> 8) & 0xff; if (marker < 1) *q++ = val & 0xff; } + if (q - (unsigned char *) data > INT_MAX) { + errno = EOVERFLOW; + return -1; + } return q - (unsigned char *) data; } + +#ifdef TEST +static int decode_flag; +static int help_flag; + +/* + * The short options are compatible with a subset of the FreeBSD contrib + * vis(1). Heimdal additions have long option names only. + */ +static struct getargs args[] = { + { "decode", 'd', arg_flag, &decode_flag, "Decode", NULL }, + { "help", 'h', arg_flag, &help_flag, "Print help message", NULL }, +}; +static size_t num_args = sizeof(args)/sizeof(args[0]); + +int +main(int argc, char **argv) +{ + unsigned char *buf = NULL; + size_t buflen = 0; + size_t bufsz = 0; + int goptind = 0; + int ret; + + setprogname("rkbase64"); + if (getarg(args, num_args, argc, argv, &goptind) || help_flag) { + arg_printusage(args, num_args, NULL, "FILE | -"); + return help_flag ? 0 : 1; + } + + argc -= goptind; + argv += goptind; + + if (help_flag) + return arg_printusage(args, num_args, NULL, "FILE | -- -"), 0; + if (argc != 1) + return arg_printusage(args, num_args, NULL, "FILE | -- -"), 1; + + if (strcmp(argv[0], "-") == 0) { + unsigned char *tmp; + unsigned char d[4096]; + size_t bytes; + + while (!feof(stdin) && !ferror(stdin)) { + bytes = fread(d, 1, sizeof(d), stdin); + if (bytes == 0) + continue; + if (buflen + bytes > bufsz) { + if ((tmp = realloc(buf, bufsz + (bufsz >> 2) + sizeof(d))) == NULL) + err(1, "Could not read stdin"); + buf = tmp; + bufsz = bufsz + (bufsz >> 2) + sizeof(d); + } + memcpy(buf + buflen, d, bytes); + buflen += bytes; + } + if (ferror(stdin)) + err(1, "Could not read stdin"); + } else { + void *d; + if ((errno = rk_undumpdata(argv[0], &d, &bufsz))) + err(1, "Could not read %s", argv[0]); + buflen = bufsz; + buf = d; + } + + if (decode_flag) { + unsigned char *d; + + if (buflen == bufsz) { + unsigned char *tmp; + + if ((tmp = realloc(buf, bufsz + 1)) == NULL) + err(1, "Could not decode data"); + buf = tmp; + bufsz++; + } + buf[buflen] = '\0'; + + if ((d = malloc(buflen * 3 / 4 + 4)) == NULL) + err(1, "Could not decode data"); + + if ((ret = rk_base64_decode((const char *)buf, d)) < 0) + err(1, "Could not decode data"); + if (fwrite(d, ret, 1, stdout) != 1) + err(1, "Could not write decoded data"); + free(d); + } else if (buf) { /* buf can be NULL if we read from an empty file */ + char *e; + + if ((ret = rk_base64_encode(buf, buflen, &e)) < 0) + err(1, "Could not encode data"); + if (fwrite(e, ret, 1, stdout) != 1) + err(1, "Could not write decoded data"); + free(e); + if (fwrite("\n", 1, 1, stdout) != 1) + err(1, "Could not write decoded data"); + } + free(buf); + return 0; +} +#endif diff --git a/lib/roken/closefrom.c b/lib/roken/closefrom.c index 770eb2c67ac1..1a950f7a8670 100644 --- a/lib/roken/closefrom.c +++ b/lib/roken/closefrom.c @@ -43,7 +43,7 @@ #include "roken.h" ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -closefrom(int fd) +rk_closefrom(int fd) { int num = getdtablesize(); diff --git a/lib/roken/clz.c b/lib/roken/clz.c new file mode 100644 index 000000000000..1a36234f16a9 --- /dev/null +++ b/lib/roken/clz.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <config.h> +#include <assert.h> + +#include "roken.h" + +#if defined(_MSC_VER) +#include <intrin.h> +#if defined(_WIN64) +#pragma intrinsic(_BitScanReverse64) +#else +#pragma intrinsic(_BitScanReverse) +#endif +#endif + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_clzll(uint64_t x) +{ +#if defined(_MSC_VER) + unsigned long r = 0; +#elif !(defined(__GNUC__) && __GNUC__ >= 4) + int r = 0; +#endif + + assert(x != 0); + +#if defined(_MSC_VER) +# if defined(_WIN64) + _BitScanReverse64(&r, x); +# else + if (_BitScanReverse(&r, (uint32_t)(x >> 32))) + return 63 - (r + 32); + _BitScanReverse(&r, (uint32_t)(x & 0xFFFFFFFF)); +# endif + + return 63 - r; +#elif (defined(__GNUC__) && __GNUC__ >= 4) + return __builtin_clzll(x); +#else + while (!(x & ((uint64_t)1 << 63))) { + x <<= 1; + ++r; + } + + return r; +#endif /* _MSC_VER || __GNUC__ */ +} diff --git a/lib/roken/copyhostent.c b/lib/roken/copyhostent.c index 4ed630210fc8..9b9dba2aea59 100644 --- a/lib/roken/copyhostent.c +++ b/lib/roken/copyhostent.c @@ -40,7 +40,7 @@ */ ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL -copyhostent (const struct hostent *h) +rk_copyhostent(const struct hostent *h) { struct hostent *res; char **p; @@ -96,4 +96,3 @@ copyhostent (const struct hostent *h) } return res; } - diff --git a/lib/roken/detach.c b/lib/roken/detach.c index 7d0f24d32ad8..4a00682511fa 100644 --- a/lib/roken/detach.c +++ b/lib/roken/detach.c @@ -44,54 +44,58 @@ static int pipefds[2] = {-1, -1}; -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_detach_prep(int argc, char **argv, char *special_arg) { + ssize_t bytes; + size_t i; pid_t child; + char **new_argv; char buf[1]; - ssize_t bytes; + char fildes[21]; int status; pipefds[0] = -1; pipefds[1] = -1; #ifdef WIN32 - if (_pipe(pipefds, 4, O_BINARY) == -1) + if (_pipe(pipefds, 4, _O_NOINHERIT | O_BINARY) == -1) err(1, "failed to setup to detach daemon (_pipe failed)"); #else if (pipe(pipefds) == -1) err(1, "failed to setup to detach daemon (pipe failed)"); #endif + new_argv = calloc(argc + 3, sizeof(*new_argv)); + if (new_argv == NULL) + err(1, "Out of memory"); + +#ifdef WIN32 + pipefds[1] = _dup(pipefds[1]); /* The new fd will be inherited */ + if (pipefds[1] == -1) + err(1, "Out of memory"); +#else + (void) fcntl(pipefds[1], F_SETFD, + fcntl(pipefds[1], F_GETFD & ~(O_CLOEXEC))); +#endif + + if (snprintf(fildes, sizeof(fildes), "%d", pipefds[1]) >= sizeof(fildes)) + err(1, "failed to setup to detach daemon (fd number %d too large)", + pipefds[1]); + + new_argv[0] = argv[0]; + new_argv[1] = special_arg; + new_argv[2] = fildes; + for (i = 1; argv[i] != NULL; i++) + new_argv[i + 2] = argv[i]; + new_argv[argc + 2] = NULL; + #ifndef WIN32 fflush(stdout); child = fork(); #else { intptr_t child_handle; - int write_side; - size_t i; - char *fildes; - char **new_argv; - - new_argv = calloc(argc + 2, sizeof(*new_argv)); - if (new_argv == NULL) - err(1, "Out of memory"); - - write_side = _dup(pipefds[1]); /* The new fd will be inherited */ - if (write_side == -1) - err(1, "Out of memory"); - - if (asprintf(&fildes, "%d", write_side) == -1 || - fildes == NULL) - err(1, "failed to setup to detach daemon (_dup failed)"); - - new_argv[0] = argv[0]; - new_argv[1] = special_arg; - new_argv[2] = fildes; - for (i = 1; argv[i] != NULL; i++) - new_argv[i + 1] = argv[i]; - new_argv[argc + 2] = NULL; _flushall(); child_handle = spawnvp(_P_NOWAIT, argv[0], new_argv); @@ -120,10 +124,17 @@ roken_detach_prep(int argc, char **argv, char *special_arg) (void) dup2(fd, STDIN_FILENO); if (fd > STDERR_FILENO) (void) close(fd); - return; + if (getenv("ROKEN_DETACH_USE_EXEC")) { + (void) execvp(argv[0], new_argv); + err(1, "failed to self-re-exec"); + } + free(new_argv); + return pipefds[1]; } #endif + /* Parent */ + free(new_argv); (void) close(pipefds[1]); pipefds[1] = -1; do { @@ -149,6 +160,8 @@ roken_detach_prep(int argc, char **argv, char *special_arg) "daemon child preparation failed (child exited)"); } _exit(0); + /* NOTREACHED */ + return -1; } #ifdef WIN32 diff --git a/lib/roken/dirent-test.c b/lib/roken/dirent-test.c index 2ac3827fb12f..2c6b5055be75 100644 --- a/lib/roken/dirent-test.c +++ b/lib/roken/dirent-test.c @@ -28,7 +28,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. * **********************************************************************/ - +#include <config.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> @@ -146,9 +146,9 @@ int teardown_test(void) (len = strlen(dirname)) > sizeof(TESTDIR)/sizeof(char) && - !strcmp(dirname + len + 1 - sizeof(TESTDIR)/sizeof(char), TESTDIR)) { + strcmp(dirname + len + 1 - sizeof(TESTDIR)/sizeof(char), TESTDIR) == 0) { - /* fallthrough */ + HEIM_FALLTHROUGH; } else { /* did we create the directory? */ @@ -162,7 +162,7 @@ int teardown_test(void) fprintf(stderr, "Can't change to test directory. Aborting cleanup.\n"); return -1; } else { - /* fallthrough */ + HEIM_FALLTHROUGH; } } else { return -1; @@ -215,12 +215,12 @@ int check_list(const char * filespec, const char ** list, int n, int expect_dot_ n_found ++; if (expect_dot_and_dotdot && - (!strcmp(e->d_name, ".") || - !strcmp(e->d_name, ".."))) + (strcmp(e->d_name, ".") == 0 || + strcmp(e->d_name, "..") == 0)) continue; for (i=0; i < n; i++) { - if (!strcmp(list[i], e->d_name)) + if (strcmp(list[i], e->d_name) == 0) break; } diff --git a/lib/roken/dlfcn.hin b/lib/roken/dlfcn.hin index cc93bf366e1e..4f2341b863a7 100644 --- a/lib/roken/dlfcn.hin +++ b/lib/roken/dlfcn.hin @@ -54,16 +54,30 @@ typedef int (__stdcall *DLSYM_RET_TYPE)(); extern "C" { #endif -/* Implementation based on - http://www.opengroup.org/onlinepubs/009695399/basedefs/dlfcn.h.html */ +/* Relocations are performed when the object is loaded. */ +#define RTLD_NOW 0 -#define RTLD_LAZY (1<<0) +/* Relocations are performed at an implementation-defined time. + * Windows API does not support lazy symbol resolving (when first reference + * to a given symbol occurs). So RTLD_LAZY implementation is same as RTLD_NOW. + */ +#define RTLD_LAZY RTLD_NOW -#define RTLD_NOW (1<<1) +/* All symbols are available for relocation processing of other modules. */ +#define RTLD_GLOBAL (1 << 1) -#define RTLD_GLOBAL (1<<2) +/* All symbols are not made available for relocation processing by other modules. */ +#define RTLD_LOCAL (1 << 2) -#define RTLD_LOCAL (1<<3) +/* These two were added in The Open Group Base Specifications Issue 6. + * Note: All other RTLD_* flags in any dlfcn.h are not standard compliant. + */ + +/* The symbol lookup happens in the normal global scope. */ +#define RTLD_DEFAULT ((void *)0LL) + +/* Specifies the next object after this one that defines name. */ +#define RTLD_NEXT ((void *)-1LL) ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL dlclose(void *); @@ -77,9 +91,12 @@ dlopen(const char *, int); ROKEN_LIB_FUNCTION DLSYM_RET_TYPE ROKEN_LIB_CALL dlsym(void *, const char *); -typedef struct Dl_info { - char *dli_fname; - char _dli_buf[MAX_PATH + 2]; +typedef struct Dl_info +{ + const char *dli_fname; /* Filename of defining object (thread unsafe and reused on every call to dladdr) */ + void *dli_fbase; /* Load address of that object */ + const char *dli_sname; /* Name of nearest lower symbol */ + void *dli_saddr; /* Exact value of nearest symbol */ } Dl_info, Dl_info_t; ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL diff --git a/lib/roken/dlfcn_w32.c b/lib/roken/dlfcn_w32.c index 96cea138241e..9da3f6fdefdd 100644 --- a/lib/roken/dlfcn_w32.c +++ b/lib/roken/dlfcn_w32.c @@ -1,185 +1,700 @@ -/*********************************************************************** - * Copyright (c) 2009, Secure Endpoints Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * - **********************************************************************/ - -#include <config.h> -#include <windows.h> -#include <dlfcn.h> -#include <strsafe.h> - -#define ERR_STR_LEN 256 - -static volatile LONG dlfcn_tls = TLS_OUT_OF_INDEXES; - -static DWORD get_tl_error_slot(void) -{ - if (dlfcn_tls == TLS_OUT_OF_INDEXES) { - DWORD slot = TlsAlloc(); - DWORD old_slot; - - if (slot == TLS_OUT_OF_INDEXES) - return dlfcn_tls; - - if ((old_slot = InterlockedCompareExchange(&dlfcn_tls, slot, - TLS_OUT_OF_INDEXES)) != - TLS_OUT_OF_INDEXES) { - - /* Lost a race */ - TlsFree(slot); - return old_slot; - } else { - return slot; - } - } - - return dlfcn_tls; -} - -static void set_error(const char * e) -{ - char * s; - char * old_s; - size_t len; - - DWORD slot = get_tl_error_slot(); - - if (slot == TLS_OUT_OF_INDEXES) - return; - - len = strlen(e) * sizeof(char) + sizeof(char); - s = LocalAlloc(LMEM_FIXED, len); - if (s == NULL) - return; - - old_s = (char *) TlsGetValue(slot); - TlsSetValue(slot, (LPVOID) s); - - if (old_s != NULL) - LocalFree(old_s); -} - -static void set_error_from_last(void) { - DWORD slot = get_tl_error_slot(); - char * s = NULL; - char * old_s; - - if (slot == TLS_OUT_OF_INDEXES) - return; - - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, - 0, GetLastError(), 0, - (LPTSTR) &s, 0, - NULL); - if (s == NULL) - return; - - old_s = (char *) TlsGetValue(slot); - TlsSetValue(slot, (LPVOID) s); - - if (old_s != NULL) - LocalFree(old_s); -} - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -dlclose(void * vhm) -{ - BOOL brv; - - brv = FreeLibrary((HMODULE) vhm); - if (!brv) { - set_error_from_last(); - } - return !brv; -} - -ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL -dlerror(void) -{ - DWORD slot = get_tl_error_slot(); - - if (slot == TLS_OUT_OF_INDEXES) - return NULL; - - return (char *) TlsGetValue(slot); -} - -ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL -dlopen(const char *fn, int flags) -{ - HMODULE hm; - UINT old_error_mode; - - /* We don't support dlopen(0, ...) on Windows.*/ - if ( fn == NULL ) { - set_error("Not implemented"); - return NULL; - } - - old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); - - hm = LoadLibraryEx(fn, 0, LOAD_WITH_ALTERED_SEARCH_PATH); - - if (hm == NULL) { - set_error_from_last(); - } - - SetErrorMode(old_error_mode); - - return (void *) hm; -} - -ROKEN_LIB_FUNCTION DLSYM_RET_TYPE ROKEN_LIB_CALL -dlsym(void * vhm, const char * func_name) -{ - HMODULE hm = (HMODULE) vhm; - - return (DLSYM_RET_TYPE)(ULONG_PTR)GetProcAddress(hm, func_name); -} - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -dladdr(void *addr, Dl_info *dli) -{ - HMODULE hm; - DWORD nsize; - - memset(dli, 0, sizeof(*dli)); - dli->dli_fname = dli->_dli_buf; - - if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (LPCTSTR)(ULONG_PTR)addr, &hm)) - return 0; - - nsize = GetModuleFileName(hm, dli->_dli_buf, sizeof(dli->_dli_buf)); - dli->_dli_buf[sizeof(dli->_dli_buf) - 1] = '\0'; - if (nsize >= sizeof(dli->_dli_buf)) - return 0; /* truncated? can't be... */ - return 1; -} +/*
+ * dlfcn-win32
+ * Copyright (c) 2007 Ramiro Polla
+ * Copyright (c) 2015 Tiancheng "Timothy" Gu
+ * Copyright (c) 2019 Pali Rohár <pali.rohar@gmail.com>
+ * Copyright (c) 2020 Ralf Habacker <ralf.habacker@freenet.de>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/*
+ * Copied from https://github.com/dlfcn-win32/dlfcn-win32 and modified only to
+ * fit Heimdal's lib/roken.
+ */
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
+#ifdef _DEBUG
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#endif
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef _MSC_VER
+/* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */
+#pragma intrinsic(_ReturnAddress)
+#else
+/* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */
+#ifndef _ReturnAddress
+#define _ReturnAddress() (__builtin_extract_return_addr(__builtin_return_address(0)))
+#endif
+#endif
+
+#ifdef DLFCN_WIN32_SHARED
+#define DLFCN_WIN32_EXPORTS
+#endif
+#include "dlfcn.h"
+
+/* Note:
+ * MSDN says these functions are not thread-safe. We make no efforts to have
+ * any kind of thread safety.
+ */
+
+typedef struct local_object {
+ HMODULE hModule;
+ struct local_object *previous;
+ struct local_object *next;
+} local_object;
+
+static local_object first_object;
+
+/* These functions implement a double linked list for the local objects. */
+static local_object *local_search( HMODULE hModule )
+{
+ local_object *pobject;
+
+ if( hModule == NULL )
+ return NULL;
+
+ for( pobject = &first_object; pobject; pobject = pobject->next )
+ if( pobject->hModule == hModule )
+ return pobject;
+
+ return NULL;
+}
+
+static BOOL local_add( HMODULE hModule )
+{
+ local_object *pobject;
+ local_object *nobject;
+
+ if( hModule == NULL )
+ return TRUE;
+
+ pobject = local_search( hModule );
+
+ /* Do not add object again if it's already on the list */
+ if( pobject )
+ return TRUE;
+
+ for( pobject = &first_object; pobject->next; pobject = pobject->next );
+
+ nobject = (local_object*) malloc( sizeof( local_object ) );
+
+ if( !nobject )
+ {
+ SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+ return FALSE;
+ }
+
+ pobject->next = nobject;
+ nobject->next = NULL;
+ nobject->previous = pobject;
+ nobject->hModule = hModule;
+
+ return TRUE;
+}
+
+static void local_rem( HMODULE hModule )
+{
+ local_object *pobject;
+
+ if( hModule == NULL )
+ return;
+
+ pobject = local_search( hModule );
+
+ if( !pobject )
+ return;
+
+ if( pobject->next )
+ pobject->next->previous = pobject->previous;
+ if( pobject->previous )
+ pobject->previous->next = pobject->next;
+
+ free( pobject );
+}
+
+/* POSIX says dlerror( ) doesn't have to be thread-safe, so we use one
+ * static buffer.
+ * MSDN says the buffer cannot be larger than 64K bytes, so we set it to
+ * the limit.
+ */
+static char error_buffer[65535];
+static BOOL error_occurred;
+
+static void save_err_str( const char *str )
+{
+ DWORD dwMessageId;
+ DWORD ret;
+ size_t pos, len;
+
+ dwMessageId = GetLastError( );
+
+ if( dwMessageId == 0 )
+ return;
+
+ len = strlen( str );
+ if( len > sizeof( error_buffer ) - 5 )
+ len = sizeof( error_buffer ) - 5;
+
+ /* Format error message to:
+ * "<argument to function that failed>": <Windows localized error message>
+ */
+ pos = 0;
+ error_buffer[pos++] = '"';
+ memcpy( error_buffer+pos, str, len );
+ pos += len;
+ error_buffer[pos++] = '"';
+ error_buffer[pos++] = ':';
+ error_buffer[pos++] = ' ';
+
+ ret = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwMessageId,
+ MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
+ error_buffer+pos, (DWORD) (sizeof(error_buffer)-pos), NULL );
+ pos += ret;
+
+ /* When FormatMessageA() fails it returns zero and does not touch buffer
+ * so add trailing null byte */
+ if( ret == 0 )
+ error_buffer[pos] = '\0';
+
+ if( pos > 1 )
+ {
+ /* POSIX says the string must not have trailing <newline> */
+ if( error_buffer[pos-2] == '\r' && error_buffer[pos-1] == '\n' )
+ error_buffer[pos-2] = '\0';
+ }
+
+ error_occurred = TRUE;
+}
+
+static void save_err_ptr_str( const void *ptr )
+{
+ char ptr_buf[2 + 2 * sizeof( ptr ) + 1];
+ char num;
+ size_t i;
+
+ ptr_buf[0] = '0';
+ ptr_buf[1] = 'x';
+
+ for( i = 0; i < 2 * sizeof( ptr ); i++ )
+ {
+ num = ( ( (ULONG_PTR) ptr ) >> ( 8 * sizeof( ptr ) - 4 * ( i + 1 ) ) ) & 0xF;
+ ptr_buf[2+i] = num + ( ( num < 0xA ) ? '0' : ( 'A' - 0xA ) );
+ }
+
+ ptr_buf[2 + 2 * sizeof( ptr )] = 0;
+
+ save_err_str( ptr_buf );
+}
+
+/* Load Psapi.dll at runtime, this avoids linking caveat */
+static BOOL MyEnumProcessModules( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded )
+{
+ static BOOL (WINAPI *EnumProcessModulesPtr)(HANDLE, HMODULE *, DWORD, LPDWORD);
+ HMODULE psapi;
+
+ if( !EnumProcessModulesPtr )
+ {
+ psapi = LoadLibraryA( "Psapi.dll" );
+ if( psapi )
+ EnumProcessModulesPtr = (BOOL (WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD)) GetProcAddress( psapi, "EnumProcessModules" );
+ if( !EnumProcessModulesPtr )
+ return 0;
+ }
+
+ return EnumProcessModulesPtr( hProcess, lphModule, cb, lpcbNeeded );
+}
+
+ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
+dlopen( const char *file, int mode )
+{
+ HMODULE hModule;
+ UINT uMode;
+
+ error_occurred = FALSE;
+
+ /* Do not let Windows display the critical-error-handler message box */
+ uMode = SetErrorMode( SEM_FAILCRITICALERRORS );
+
+ if( file == 0 )
+ {
+ /* POSIX says that if the value of file is 0, a handle on a global
+ * symbol object must be provided. That object must be able to access
+ * all symbols from the original program file, and any objects loaded
+ * with the RTLD_GLOBAL flag.
+ * The return value from GetModuleHandle( ) allows us to retrieve
+ * symbols only from the original program file. EnumProcessModules() is
+ * used to access symbols from other libraries. For objects loaded
+ * with the RTLD_LOCAL flag, we create our own list later on. They are
+ * excluded from EnumProcessModules() iteration.
+ */
+ hModule = GetModuleHandle( NULL );
+
+ if( !hModule )
+ save_err_str( "(null)" );
+ }
+ else
+ {
+ HANDLE hCurrentProc;
+ DWORD dwProcModsBefore, dwProcModsAfter;
+ char lpFileName[MAX_PATH];
+ size_t i, len;
+
+ len = strlen( file );
+
+ if( len >= sizeof( lpFileName ) )
+ {
+ SetLastError( ERROR_FILENAME_EXCED_RANGE );
+ save_err_str( file );
+ hModule = NULL;
+ }
+ else
+ {
+ /* MSDN says backslashes *must* be used instead of forward slashes. */
+ for( i = 0; i < len; i++ )
+ {
+ if( file[i] == '/' )
+ lpFileName[i] = '\\';
+ else
+ lpFileName[i] = file[i];
+ }
+ lpFileName[len] = '\0';
+
+ hCurrentProc = GetCurrentProcess( );
+
+ if( MyEnumProcessModules( hCurrentProc, NULL, 0, &dwProcModsBefore ) == 0 )
+ dwProcModsBefore = 0;
+
+ /* POSIX says the search path is implementation-defined.
+ * LOAD_WITH_ALTERED_SEARCH_PATH is used to make it behave more closely
+ * to UNIX's search paths (start with system folders instead of current
+ * folder).
+ */
+ hModule = LoadLibraryExA( lpFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
+
+ if( !hModule )
+ {
+ save_err_str( lpFileName );
+ }
+ else
+ {
+ if( MyEnumProcessModules( hCurrentProc, NULL, 0, &dwProcModsAfter ) == 0 )
+ dwProcModsAfter = 0;
+
+ /* If the object was loaded with RTLD_LOCAL, add it to list of local
+ * objects, so that its symbols cannot be retrieved even if the handle for
+ * the original program file is passed. POSIX says that if the same
+ * file is specified in multiple invocations, and any of them are
+ * RTLD_GLOBAL, even if any further invocations use RTLD_LOCAL, the
+ * symbols will remain global. If number of loaded modules was not
+ * changed after calling LoadLibraryEx(), it means that library was
+ * already loaded.
+ */
+ if( (mode & RTLD_LOCAL) && dwProcModsBefore != dwProcModsAfter )
+ {
+ if( !local_add( hModule ) )
+ {
+ save_err_str( lpFileName );
+ FreeLibrary( hModule );
+ hModule = NULL;
+ }
+ }
+ else if( !(mode & RTLD_LOCAL) && dwProcModsBefore == dwProcModsAfter )
+ {
+ local_rem( hModule );
+ }
+ }
+ }
+ }
+
+ /* Return to previous state of the error-mode bit flags. */
+ SetErrorMode( uMode );
+
+ return (void *) hModule;
+}
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+dlclose( void *handle )
+{
+ HMODULE hModule = (HMODULE) handle;
+ BOOL ret;
+
+ error_occurred = FALSE;
+
+ ret = FreeLibrary( hModule );
+
+ /* If the object was loaded with RTLD_LOCAL, remove it from list of local
+ * objects.
+ */
+ if( ret )
+ local_rem( hModule );
+ else
+ save_err_ptr_str( handle );
+
+ /* dlclose's return value in inverted in relation to FreeLibrary's. */
+ ret = !ret;
+
+ return (int) ret;
+}
+
+__declspec(noinline) /* Needed for _ReturnAddress() */
+ROKEN_LIB_FUNCTION DLSYM_RET_TYPE ROKEN_LIB_CALL
+dlsym( void *handle, const char *name )
+{
+ FARPROC symbol;
+ HMODULE hCaller;
+ HMODULE hModule;
+ HANDLE hCurrentProc;
+
+ error_occurred = FALSE;
+
+ symbol = NULL;
+ hCaller = NULL;
+ hModule = GetModuleHandle( NULL );
+ hCurrentProc = GetCurrentProcess( );
+
+ if( handle == RTLD_DEFAULT )
+ {
+ /* The symbol lookup happens in the normal global scope; that is,
+ * a search for a symbol using this handle would find the same
+ * definition as a direct use of this symbol in the program code.
+ * So use same lookup procedure as when filename is NULL.
+ */
+ handle = hModule;
+ }
+ else if( handle == RTLD_NEXT )
+ {
+ /* Specifies the next object after this one that defines name.
+ * This one refers to the object containing the invocation of dlsym().
+ * The next object is the one found upon the application of a load
+ * order symbol resolution algorithm. To get caller function of dlsym()
+ * use _ReturnAddress() intrinsic. To get HMODULE of caller function
+ * use standard GetModuleHandleExA() function.
+ */
+ if( !GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) _ReturnAddress( ), &hCaller ) )
+ goto end;
+ }
+
+ if( handle != RTLD_NEXT )
+ {
+ symbol = GetProcAddress( (HMODULE) handle, name );
+
+ if( symbol != NULL )
+ goto end;
+ }
+
+ /* If the handle for the original program file is passed, also search
+ * in all globally loaded objects.
+ */
+
+ if( hModule == handle || handle == RTLD_NEXT )
+ {
+ HMODULE *modules;
+ DWORD cbNeeded;
+ DWORD dwSize;
+ size_t i;
+
+ /* GetModuleHandle( NULL ) only returns the current program file. So
+ * if we want to get ALL loaded module including those in linked DLLs,
+ * we have to use EnumProcessModules( ).
+ */
+ if( MyEnumProcessModules( hCurrentProc, NULL, 0, &dwSize ) != 0 )
+ {
+ modules = malloc( dwSize );
+ if( modules )
+ {
+ if( MyEnumProcessModules( hCurrentProc, modules, dwSize, &cbNeeded ) != 0 && dwSize == cbNeeded )
+ {
+ for( i = 0; i < dwSize / sizeof( HMODULE ); i++ )
+ {
+ if( handle == RTLD_NEXT && hCaller )
+ {
+ /* Next modules can be used for RTLD_NEXT */
+ if( hCaller == modules[i] )
+ hCaller = NULL;
+ continue;
+ }
+ if( local_search( modules[i] ) )
+ continue;
+ symbol = GetProcAddress( modules[i], name );
+ if( symbol != NULL )
+ {
+ free( modules );
+ goto end;
+ }
+ }
+
+ }
+ free( modules );
+ }
+ else
+ {
+ SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+ goto end;
+ }
+ }
+ }
+
+end:
+ if( symbol == NULL )
+ {
+ if( GetLastError() == 0 )
+ SetLastError( ERROR_PROC_NOT_FOUND );
+ save_err_str( name );
+ }
+
+ return *(void **) (&symbol);
+}
+
+ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL
+dlerror( void )
+{
+ /* If this is the second consecutive call to dlerror, return NULL */
+ if( !error_occurred )
+ return NULL;
+
+ /* POSIX says that invoking dlerror( ) a second time, immediately following
+ * a prior invocation, shall result in NULL being returned.
+ */
+ error_occurred = FALSE;
+
+ return error_buffer;
+}
+
+/* See https://docs.microsoft.com/en-us/archive/msdn-magazine/2002/march/inside-windows-an-in-depth-look-into-the-win32-portable-executable-file-format-part-2
+ * for details */
+
+/* Get specific image section */
+static BOOL get_image_section( HMODULE module, int index, void **ptr, DWORD *size )
+{
+ IMAGE_DOS_HEADER *dosHeader;
+ IMAGE_OPTIONAL_HEADER *optionalHeader;
+
+ dosHeader = (IMAGE_DOS_HEADER *) module;
+
+ if( dosHeader->e_magic != 0x5A4D )
+ return FALSE;
+
+ optionalHeader = (IMAGE_OPTIONAL_HEADER *) ( (BYTE *) module + dosHeader->e_lfanew + 24 );
+
+ if( optionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC )
+ return FALSE;
+
+ if( index < 0 || index > IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR )
+ return FALSE;
+
+ if( optionalHeader->DataDirectory[index].Size == 0 || optionalHeader->DataDirectory[index].VirtualAddress == 0 )
+ return FALSE;
+
+ if( size != NULL )
+ *size = optionalHeader->DataDirectory[index].Size;
+
+ *ptr = (void *)( (BYTE *) module + optionalHeader->DataDirectory[index].VirtualAddress );
+
+ return TRUE;
+}
+
+/* Return symbol name for a given address */
+static const char *get_symbol_name( HMODULE module, IMAGE_IMPORT_DESCRIPTOR *iid, void *addr, void **func_address )
+{
+ int i;
+ void *candidateAddr = NULL;
+ const char *candidateName = NULL;
+ BYTE *base = (BYTE *) module; /* Required to have correct calculations */
+
+ for( i = 0; iid[i].Characteristics != 0 && iid[i].FirstThunk != 0; i++ )
+ {
+ IMAGE_THUNK_DATA *thunkILT = (IMAGE_THUNK_DATA *)( base + iid[i].Characteristics );
+ IMAGE_THUNK_DATA *thunkIAT = (IMAGE_THUNK_DATA *)( base + iid[i].FirstThunk );
+
+ for( ; thunkILT->u1.AddressOfData != 0; thunkILT++, thunkIAT++ )
+ {
+ IMAGE_IMPORT_BY_NAME *nameData;
+
+ if( IMAGE_SNAP_BY_ORDINAL( thunkILT->u1.Ordinal ) )
+ continue;
+
+ if( (void *) thunkIAT->u1.Function > addr || candidateAddr >= (void *) thunkIAT->u1.Function )
+ continue;
+
+ candidateAddr = (void *) thunkIAT->u1.Function;
+ nameData = (IMAGE_IMPORT_BY_NAME *)( base + (ULONG_PTR) thunkILT->u1.AddressOfData );
+ candidateName = (const char *) nameData->Name;
+ }
+ }
+
+ *func_address = candidateAddr;
+ return candidateName;
+}
+
+static BOOL is_valid_address( void *addr )
+{
+ MEMORY_BASIC_INFORMATION info;
+ SIZE_T result;
+
+ if( addr == NULL )
+ return FALSE;
+
+ /* check valid pointer */
+ result = VirtualQuery( addr, &info, sizeof( info ) );
+
+ if( result == 0 || info.AllocationBase == NULL || info.AllocationProtect == 0 || info.AllocationProtect == PAGE_NOACCESS )
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Return state if address points to an import thunk
+ *
+ * An import thunk is setup with a 'jmp' instruction followed by an
+ * absolute address (32bit) or relative offset (64bit) pointing into
+ * the import address table (iat), which is partially maintained by
+ * the runtime linker.
+ */
+static BOOL is_import_thunk( void *addr )
+{
+ return *(short *) addr == 0x25ff ? TRUE : FALSE;
+}
+
+/* Return adress from the import address table (iat),
+ * if the original address points to a thunk table entry.
+ */
+static void *get_address_from_import_address_table( void *iat, DWORD iat_size, void *addr )
+{
+ BYTE *thkp = (BYTE *) addr;
+ /* Get offset from thunk table (after instruction 0xff 0x25)
+ * 4018c8 <_VirtualQuery>: ff 25 4a 8a 00 00
+ */
+ ULONG offset = *(ULONG *)( thkp + 2 );
+#ifdef _WIN64
+ /* On 64 bit the offset is relative
+ * 4018c8: ff 25 4a 8a 00 00 jmpq *0x8a4a(%rip) # 40a318 <__imp_VirtualQuery>
+ * And can be also negative (MSVC in WDK)
+ * 100002f20: ff 25 3a e1 ff ff jmpq *-0x1ec6(%rip) # 0x100001060
+ * So cast to signed LONG type
+ */
+ BYTE *ptr = (BYTE *)( thkp + 6 + (LONG) offset );
+#else
+ /* On 32 bit the offset is absolute
+ * 4019b4: ff 25 90 71 40 00 jmp *0x40719
+ */
+ BYTE *ptr = (BYTE *) offset;
+#endif
+
+ if( !is_valid_address( ptr ) || ptr < (BYTE *) iat || ptr > (BYTE *) iat + iat_size )
+ return NULL;
+
+ return *(void **) ptr;
+}
+
+/* Holds module filename */
+static char module_filename[2*MAX_PATH];
+
+static BOOL fill_module_info( void *addr, Dl_info *info )
+{
+ HMODULE hModule;
+ DWORD dwSize;
+
+ if( !GetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, addr, &hModule ) || hModule == NULL )
+ return FALSE;
+
+ dwSize = GetModuleFileNameA( hModule, module_filename, sizeof( module_filename ) );
+
+ if( dwSize == 0 || dwSize == sizeof( module_filename ) )
+ return FALSE;
+
+ info->dli_fbase = (void *) hModule;
+ info->dli_fname = module_filename;
+
+ return TRUE;
+}
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+dladdr( void *addr, Dl_info *info )
+{
+ void *realAddr, *funcAddress = NULL;
+ HMODULE hModule;
+ IMAGE_IMPORT_DESCRIPTOR *iid;
+ DWORD iidSize = 0;
+
+ if( addr == NULL || info == NULL )
+ return 0;
+
+ hModule = GetModuleHandleA( NULL );
+ if( hModule == NULL )
+ return 0;
+
+ if( !is_valid_address( addr ) )
+ return 0;
+
+ realAddr = addr;
+
+ if( !get_image_section( hModule, IMAGE_DIRECTORY_ENTRY_IMPORT, (void **) &iid, &iidSize ) )
+ return 0;
+
+ if( is_import_thunk( addr ) )
+ {
+ void *iat;
+ void *iatAddr = NULL;
+ DWORD iatSize = 0;
+
+ if( !get_image_section( hModule, IMAGE_DIRECTORY_ENTRY_IAT, &iat, &iatSize ) )
+ {
+ /* Fallback for cases where the iat is not defined,
+ * for example i586-mingw32msvc-gcc */
+ if( iid == NULL || iid->Characteristics == 0 || iid->FirstThunk == 0 )
+ return 0;
+
+ iat = (void *)( (BYTE *) hModule + iid->FirstThunk );
+ /* We assume that in this case iid and iat's are in linear order */
+ iatSize = iidSize - (DWORD) ( (BYTE *) iat - (BYTE *) iid );
+ }
+
+ iatAddr = get_address_from_import_address_table( iat, iatSize, addr );
+ if( iatAddr == NULL )
+ return 0;
+
+ realAddr = iatAddr;
+ }
+
+ if( !fill_module_info( realAddr, info ) )
+ return 0;
+
+ info->dli_sname = get_symbol_name( hModule, iid, realAddr, &funcAddress );
+
+ info->dli_saddr = !info->dli_sname ? NULL : funcAddress ? funcAddress : realAddr;
+ return 1;
+}
+
+#ifdef DLFCN_WIN32_SHARED
+BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
+{
+ (void) hinstDLL;
+ (void) fdwReason;
+ (void) lpvReserved;
+ return TRUE;
+}
+#endif
diff --git a/lib/roken/dumpdata.c b/lib/roken/dumpdata.c index 252744e28e2f..a8b3efefcff4 100644 --- a/lib/roken/dumpdata.c +++ b/lib/roken/dumpdata.c @@ -51,8 +51,86 @@ rk_dumpdata (const char *filename, const void *buf, size_t size) close(fd); } +/* For not-regular files */ +static int +undump_not_file(int fd, char **out, size_t *size, int nul_terminate) +{ + size_t lim = 10 * 1024 * 1024; + size_t bufsz = 0; + size_t sz = 0; + char *buf = NULL; + char *tmp; + + *out = NULL; + if (size && *size != 0 && *size < lim) + lim = *size; + if (size) + *size = 0; + + /* + * We can't use net_read() if we're on WIN32 because that really wants a + * socket FD, which is in a distinct FD namespace from those returned by + * open() on Windows. + */ + do { + ssize_t bytes; + + if (sz == bufsz) { + if (bufsz == 0) + bufsz = 1024; + else + bufsz += bufsz >> 1; + + tmp = realloc(buf, bufsz); + if (tmp == NULL) { + free(buf); + return ENOMEM; + } + buf = tmp; + } + + bytes = read(fd, buf + sz, bufsz - sz); + if (bytes == 0) + break; + if (bytes < 0 && + (errno == EAGAIN || errno == EWOULDBLOCK)) + continue; + if (bytes < 0) { + free(buf); + return errno; + } + sz += bytes; + } while (sz < lim); + + *out = buf; + if (size) + *size = sz; + + if (!nul_terminate) + return 0; + + if (bufsz > sz) { + buf[sz] = '\0'; + return 0; + } + + *out = tmp = realloc(buf, bufsz + 1); + if (tmp == NULL) { + free(buf); + return ENOMEM; + } + buf = tmp; + buf[sz] = '\0'; + return 0; +} + /* - * Read all data from a filename, care about errors. + * Read all data from a file, care about errors. + * + * If `*size' is not zero and the file is not a regular file, then up to that + * many bytes will be read. + * + * Returns zero on success or a system error code on failure. */ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL @@ -71,6 +149,17 @@ rk_undumpdata(const char *filename, void **buf, size_t *size) ret = errno; goto out; } + if (!S_ISREG(sb.st_mode)) { + char *char_buf; + + ret = undump_not_file(fd, &char_buf, size, 0); + (void) close(fd); + *buf = char_buf; + return ret; + } + + if (sb.st_size < 0) + sb.st_size = 0; *buf = malloc(sb.st_size); if (*buf == NULL) { ret = ENOMEM; @@ -78,7 +167,7 @@ rk_undumpdata(const char *filename, void **buf, size_t *size) } *size = sb.st_size; - sret = net_read(fd, *buf, *size); + sret = read(fd, *buf, *size); if (sret < 0) ret = errno; else if (sret != (ssize_t)*size) @@ -94,3 +183,67 @@ rk_undumpdata(const char *filename, void **buf, size_t *size) close(fd); return ret; } + +/* + * Read all text from a file. + * + * Outputs a C string. It is up to the caller to check for embedded NULs. + * The number of bytes read will be stored in `*size' if `size' is not NULL. + * + * If `size' is not NULL and `*size' is not zero and the file is not a regular + * file, then up to that many bytes will be read. + * + * Returns zero on success or a system error code on failure. + */ + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_undumptext(const char *filename, char **out, size_t *size) +{ + struct stat sb; + int fd, ret; + ssize_t sret; + char *buf; + + *out = NULL; + + fd = open(filename, O_RDONLY, 0); + if (fd < 0) + return errno; + if (fstat(fd, &sb) != 0) { + (void) close(fd); + return errno; + } + if (!S_ISREG(sb.st_mode)) { + ret = undump_not_file(fd, out, size, 1); + (void) close(fd); + return ret; + } + + if (sb.st_size < 0) + sb.st_size = 0; + buf = malloc(sb.st_size + 1); + if (buf == NULL) { + ret = ENOMEM; + goto out; + } + if (size) + *size = sb.st_size; + + sret = read(fd, buf, sb.st_size); + if (sret < 0) + ret = errno; + else if (sret != (ssize_t)sb.st_size) + ret = EINVAL; + else + ret = 0; + +out: + if (ret) { + free(buf); + } else { + buf[sb.st_size] = '\0'; + *out = buf; + } + close(fd); + return ret; +} diff --git a/lib/roken/ecalloc.cat3 b/lib/roken/ecalloc.cat3 deleted file mode 100644 index c22a85444539..000000000000 --- a/lib/roken/ecalloc.cat3 +++ /dev/null @@ -1,46 +0,0 @@ -ECALLOC(3) BSD Library Functions Manual ECALLOC(3) - -[1mNAME[0m - [1mecalloc[22m, [1memalloc[22m, [1meread[22m, [1merealloc[22m, [1mesetenv[22m, [1mestrdup[22m, [1mewrite [22m-- exit-on- - failure wrapper functions - -[1mLIBRARY[0m - The roken library (libroken, -lroken) - -[1mSYNOPSIS[0m - [1m#include <roken.h>[0m - - [4mvoid[24m [4m*[0m - [1mecalloc[22m([4msize_t[24m [4mnumber[24m, [4msize_t[24m [4msize[24m); - - [4mvoid[24m [4m*[0m - [1memalloc[22m([4msize_t[24m [4msz[24m); - - [4mssize_t[0m - [1meread[22m([4mint[24m [4mfd[24m, [4mvoid[24m [4m*buf[24m, [4msize_t[24m [4mnbytes[24m); - - [4mvoid[24m [4m*[0m - [1merealloc[22m([4mvoid[24m [4m*ptr[24m, [4msize_t[24m [4msz[24m); - - [4mvoid[0m - [1mesetenv[22m([4mconst[24m [4mchar[24m [4m*var[24m, [4mconst[24m [4mchar[24m [4m*val[24m, [4mint[24m [4mrewrite[24m); - - [4mchar[24m [4m*[0m - [1mestrdup[22m([4mconst[24m [4mchar[24m [4m*str[24m); - - [4mssize_t[0m - [1mewrite[22m([4mint[24m [4mfd[24m, [4mconst[24m [4mvoid[24m [4m*buf[24m, [4msize_t[24m [4mnbytes[24m); - -[1mDESCRIPTION[0m - These functions do the same as the ones without the "e" prefix, but if - there is an error they will print a message with errx(3), and exit. For - [1meread [22mand [1mewrite [22mthis is also true for partial data. - - This is useful in applications when there is no need for a more advanced - failure mode. - -[1mSEE ALSO[0m - read(2), write(2), calloc(3), errx(3), malloc(3), realloc(3), setenv(3), - strdup(3) - -HEIMDAL August 14, 2003 HEIMDAL diff --git a/lib/roken/environment.c b/lib/roken/environment.c index 64c354d62bbd..a14f27b8a931 100644 --- a/lib/roken/environment.c +++ b/lib/roken/environment.c @@ -62,7 +62,8 @@ find_var(char **env, char *assignment, size_t len) static int read_env_file(FILE *F, char ***env, int *assigned) { - int idx = 0; + size_t alloced = 0; + size_t idx = 0; int i; char **l; char buf[BUFSIZ], *p, *r; @@ -71,8 +72,11 @@ read_env_file(FILE *F, char ***env, int *assigned) *assigned = 0; - for(idx = 0; *env != NULL && (*env)[idx] != NULL; idx++); l = *env; + for (idx = 0; l != NULL && l[idx] != NULL; idx++) + ; + if (l) + alloced = idx + 1; /* This is somewhat more relaxed on what it accepts then * Wietses sysv_environ from K4 was... @@ -90,7 +94,11 @@ read_env_file(FILE *F, char ***env, int *assigned) continue; if((i = find_var(l, p, r - p + 1)) >= 0) { - char *val = strdup(p); + char *val; + + if ((size_t)i >= alloced) + continue; /* Doesn't happen (fix scan-build noise) */ + val = strdup(p); if(val == NULL) { ret = ENOMEM; break; @@ -114,6 +122,7 @@ read_env_file(FILE *F, char ***env, int *assigned) break; } l[++idx] = NULL; + alloced = idx + 1; (*assigned)++; } if(ferror(F)) diff --git a/lib/roken/err.c b/lib/roken/err.c index 5fbe84fdf761..592ed69d31ad 100644 --- a/lib/roken/err.c +++ b/lib/roken/err.c @@ -33,9 +33,10 @@ #include <config.h> +#include "roken.h" #include "err.h" -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL err(int eval, const char *fmt, ...) { va_list ap; diff --git a/lib/roken/err.hin b/lib/roken/err.hin index c5343c49adea..905b1ebcf11c 100644 --- a/lib/roken/err.hin +++ b/lib/roken/err.hin @@ -47,30 +47,39 @@ #endif #ifndef ROKEN_LIB_FUNCTION -#ifdef _WIN32 -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL __cdecl -#else -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL + #define ROKEN_LIB_FUNCTION #endif +#ifndef ROKEN_LIB_NORETURN_FUNCTION + #ifdef _WIN32 + #define ROKEN_LIB_NORETURN_FUNCTION __declspec(noreturn) + #else + #define ROKEN_LIB_NORETURN_FUNCTION + #endif +#endif +#ifndef ROKEN_LIB_CALL + #ifdef _WIN32 + #define ROKEN_LIB_CALL __cdecl + #else + #define ROKEN_LIB_CALL + #endif #endif -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL verr(int eval, const char *fmt, va_list ap) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL err(int eval, const char *fmt, ...) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3))); -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL verrx(int eval, const char *fmt, va_list ap) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL errx(int eval, const char *fmt, ...) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3))); + ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL vwarn(const char *fmt, va_list ap) __attribute__ ((__format__ (__printf__, 1, 0))); diff --git a/lib/roken/errx.c b/lib/roken/errx.c index f75ad0179e3b..121c7070d168 100644 --- a/lib/roken/errx.c +++ b/lib/roken/errx.c @@ -35,7 +35,7 @@ #include "err.h" -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL errx(int eval, const char *fmt, ...) { va_list ap; diff --git a/lib/roken/fnmatch.c b/lib/roken/fnmatch.c index 7dfe492179d1..34da19f2cb1c 100644 --- a/lib/roken/fnmatch.c +++ b/lib/roken/fnmatch.c @@ -129,7 +129,7 @@ rk_fnmatch(const char *pattern, const char *string, int flags) --pattern; } } - /* FALLTHROUGH */ + HEIM_FALLTHROUGH; default: if (c != *string++) return (FNM_NOMATCH); diff --git a/lib/roken/freeaddrinfo.c b/lib/roken/freeaddrinfo.c index 7132e95dd38d..80a7487b8d5e 100644 --- a/lib/roken/freeaddrinfo.c +++ b/lib/roken/freeaddrinfo.c @@ -40,7 +40,7 @@ */ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL -freeaddrinfo(struct addrinfo *ai) +rk_freeaddrinfo(struct addrinfo *ai) { struct addrinfo *tofree; diff --git a/lib/roken/freehostent.c b/lib/roken/freehostent.c index 61fbb223b5ec..05dd0fe385ce 100644 --- a/lib/roken/freehostent.c +++ b/lib/roken/freehostent.c @@ -40,7 +40,7 @@ */ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL -freehostent (struct hostent *h) +rk_freehostent(struct hostent *h) { char **p; diff --git a/lib/roken/verify.c b/lib/roken/fseeko.c index fc8fc57b6f40..b6ffaa2ba606 100644 --- a/lib/roken/verify.c +++ b/lib/roken/fseeko.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan + * Copyright (c) 2017 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,27 +33,16 @@ #include <config.h> -#include <stdio.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_CRYPT_H -#include <crypt.h> -#endif #include "roken.h" +#ifndef HAVE_FSEEKO ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unix_verify_user(char *user, char *password) +fseeko(FILE *f, off_t o, int w) { - struct passwd *pw; - - pw = k_getpwnam(user); - if(pw == NULL) - return -1; - if(strlen(pw->pw_passwd) == 0 && strlen(password) == 0) - return 0; - if(strcmp(crypt(password, pw->pw_passwd), pw->pw_passwd) == 0) - return 0; - return -1; +#ifdef HAVE__FSEEKI64 + return _fseeki64(f, o, w); +#else + return fseek(f, o, w); +#endif } - +#endif diff --git a/lib/roken/k_getpwuid.c b/lib/roken/ftello.c index d533738d9d09..cd3b84b80c01 100644 --- a/lib/roken/k_getpwuid.c +++ b/lib/roken/ftello.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan + * Copyright (c) 2017 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -34,28 +34,15 @@ #include <config.h> #include "roken.h" -#ifdef HAVE_SHADOW_H -#include <shadow.h> -#endif -ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL -k_getpwuid (uid_t uid) +#ifndef HAVE_FTELLO +ROKEN_LIB_FUNCTION off_t ROKEN_LIB_CALL +ftello(FILE *f) { - struct passwd *p; - - p = getpwuid (uid); -#if defined(HAVE_GETSPNAM) && defined(HAVE_STRUCT_SPWD) - if (p) - { - struct spwd *spwd; - - spwd = getspnam (p->pw_name); - if (spwd) - p->pw_passwd = spwd->sp_pwdp; - endspent (); - } +#ifdef HAVE__FTELLI64 + return _ftelli64(f); #else - endpwent (); + return ftell(f); #endif - return p; } +#endif diff --git a/lib/roken/getaddrinfo-test.c b/lib/roken/getaddrinfo-test.c index a2b726f9a2d2..6bdc603fd409 100644 --- a/lib/roken/getaddrinfo-test.c +++ b/lib/roken/getaddrinfo-test.c @@ -129,6 +129,9 @@ main(int argc, char **argv) return 0; } + if (rk_SOCK_INIT()) + errx(1, "Failed to initialize sockets (%s)", strerror(rk_SOCK_ERRNO)); + argc -= optidx; argv += optidx; @@ -143,5 +146,6 @@ main(int argc, char **argv) doit (nodename, argv[i+1]); } + rk_SOCK_EXIT(); return 0; } diff --git a/lib/roken/getaddrinfo.c b/lib/roken/getaddrinfo.c index ae21bf11090c..47affba59f51 100644 --- a/lib/roken/getaddrinfo.c +++ b/lib/roken/getaddrinfo.c @@ -188,7 +188,7 @@ get_null (const struct addrinfo *hints, struct addrinfo *first = NULL; struct addrinfo **current = &first; int family = PF_UNSPEC; - int ret = 0; + int ret = EAI_FAMILY; if (hints != NULL) family = hints->ai_family; @@ -209,8 +209,6 @@ get_null (const struct addrinfo *hints, if (family == PF_INET6 || family == PF_UNSPEC) { ret = add_one (port, protocol, socktype, ¤t, const_v6, &v6_addr, NULL); - if (ret) - return ret; } #endif if (family == PF_INET || family == PF_UNSPEC) { @@ -368,10 +366,10 @@ get_nodes (const char *nodename, */ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -getaddrinfo(const char *nodename, - const char *servname, - const struct addrinfo *hints, - struct addrinfo **res) +rk_getaddrinfo(const char *nodename, + const char *servname, + const struct addrinfo *hints, + struct addrinfo **res) { int ret; int port = 0; @@ -411,6 +409,6 @@ getaddrinfo(const char *nodename, ret = get_null (hints, port, protocol, socktype, res); } if (ret) - freeaddrinfo (*res); + rk_freeaddrinfo(*res); return ret; } diff --git a/lib/roken/getarg.cat3 b/lib/roken/getarg.cat3 deleted file mode 100644 index bc3d11fa82e4..000000000000 --- a/lib/roken/getarg.cat3 +++ /dev/null @@ -1,230 +0,0 @@ -GETARG(3) BSD Library Functions Manual GETARG(3) - -[1mNAME[0m - [1mgetarg[22m, [1marg_printusage [22m-- collect command line options - -[1mSYNOPSIS[0m - [1m#include <getarg.h>[0m - - [4mint[0m - [1mgetarg[22m([4mstruct[24m [4mgetargs[24m [4m*args[24m, [4msize_t[24m [4mnum_args[24m, [4mint[24m [4margc[24m, [4mchar[24m [4m**argv[24m, - [4mint[24m [4m*optind[24m); - - [4mvoid[0m - [1marg_printusage[22m([4mstruct[24m [4mgetargs[24m [4m*args[24m, [4msize_t[24m [4mnum_args[24m, - [4mconst[24m [4mchar[24m [4m*progname[24m, [4mconst[24m [4mchar[24m [4m*extra_string[24m); - -[1mDESCRIPTION[0m - [1mgetarg[22m() collects any command line options given to a program in an eas- - ily used way. [1marg_printusage[22m() pretty-prints the available options, with - a short help text. - - [4margs[24m is the option specification to use, and it's an array of [4mstruct[0m - [4mgetargs[24m elements. [4mnum_args[24m is the size of [4margs[24m (in elements). [4margc[24m and - [4margv[24m are the argument count and argument vector to extract option from. - [4moptind[24m is a pointer to an integer where the index to the last processed - argument is stored, it must be initialised to the first index (minus one) - to process (normally 0) before the first call. - - [4marg_printusage[24m take the same [4margs[24m and [4mnum_args[24m as getarg; [4mprogname[24m is the - name of the program (to be used in the help text), and [4mextra_string[24m is a - string to print after the actual options to indicate more arguments. The - usefulness of this function is realised only be people who has used pro- - grams that has help strings that doesn't match what the code does. - - The [4mgetargs[24m struct has the following elements. - - struct getargs{ - const char *long_name; - char short_name; - enum { arg_integer, - arg_string, - arg_flag, - arg_negative_flag, - arg_strings, - arg_double, - arg_collect - } type; - void *value; - const char *help; - const char *arg_help; - }; - - [4mlong_name[24m is the long name of the option, it can be NULL, if you don't - want a long name. [4mshort_name[24m is the characted to use as short option, it - can be zero. If the option has a value the [4mvalue[24m field gets filled in - with that value interpreted as specified by the [4mtype[24m field. [4mhelp[24m is a - longer help string for the option as a whole, if it's NULL the help text - for the option is omitted (but it's still displayed in the synopsis). - [4marg_help[24m is a description of the argument, if NULL a default value will - be used, depending on the type of the option: - - arg_integer the argument is a signed integer, and [4mvalue[24m should - point to an [4mint[24m. - - [4marg_string[24m the argument is a string, and [4mvalue[24m should point to a - [4mchar*[24m. - - [4marg_flag[24m the argument is a flag, and [4mvalue[24m should point to a - [4mint[24m. It gets filled in with either zero or one, de- - pending on how the option is given, the normal case - being one. Note that if the option isn't given, the - value isn't altered, so it should be initialised to - some useful default. - - [4marg_negative_flag[24m this is the same as [4marg_flag[24m but it reverses the mean- - ing of the flag (a given short option clears the - flag), and the synopsis of a long option is negated. - - [4marg_strings[24m the argument can be given multiple times, and the val- - ues are collected in an array; [4mvalue[24m should be a - pointer to a [4mstruct[24m [4mgetarg_strings[24m structure, which - holds a length and a string pointer. - - [4marg_double[24m argument is a double precision floating point value, - and [4mvalue[24m should point to a [4mdouble[24m. - - [4marg_collect[24m allows more fine-grained control of the option parsing - process. [4mvalue[24m should be a pointer to a - [4mgetarg_collect_info[24m structure: - - typedef int (*getarg_collect_func)(int short_opt, - int argc, - char **argv, - int *optind, - int *optarg, - void *data); - - typedef struct getarg_collect_info { - getarg_collect_func func; - void *data; - } getarg_collect_info; - - With the [4mfunc[24m member set to a function to call, and - [4mdata[24m to some application specific data. The parameters - to the collect function are: - - [4mshort_flag[24m non-zero if this call is via a short option - flag, zero otherwise - - [4margc[24m, [4margv[24m the whole argument list - - [4moptind[24m pointer to the index in argv where the flag is - - [4moptarg[24m pointer to the index in argv[*optind] where the - flag name starts - - [4mdata[24m application specific data - - You can modify [4m*optind[24m, and [4m*optarg[24m, but to do this - correct you (more or less) have to know about the in- - ner workings of getarg. - - You can skip parts of arguments by increasing [4m*optarg[0m - (you could implement the [1m-z[4m[22m3[24m set of flags from [1mgzip[0m - with this), or whole argument strings by increasing - [4m*optind[24m (let's say you want a flag [1m-c [4m[22mx[24m [4my[24m [4mz[24m to specify - a coordinate); if you also have to set [4m*optarg[24m to a - sane value. - - The collect function should return one of - ARG_ERR_NO_MATCH, ARG_ERR_BAD_ARG, ARG_ERR_NO_ARG, - ENOMEM on error, zero otherwise. - - For your convenience there is a function, - [1mgetarg_optarg[22m(), that returns the traditional argument - string, and you pass it all arguments, sans data, that - where given to the collection function. - - Don't use this more this unless you absolutely have - to. - - Option parsing is similar to what getopt uses. Short options without ar- - guments can be compressed ([1m-xyz [22mis the same as [1m-x -y -z[22m), and short op- - tions with arguments take these as either the rest of the argv-string or - as the next option ([1m-o[4m[22mfoo[24m, or [1m-o [4m[22mfoo[24m). - - Long option names are prefixed with -- (double dash), and the value with - a = (equal), [1m--foo=[4m[22mbar[24m. Long option flags can either be specified as - they are ([1m--help[22m), or with an (boolean parsable) option ([1m--help=[4m[22myes[24m, - [1m--help=[4m[22mtrue[24m, or similar), or they can also be negated ([1m--no-help [22mis the - same as [1m--help=[22mno), and if you're really confused you can do it multiple - times ([1m--no-no-help=[4m[22mfalse[24m, or even [1m--no-no-help=[4m[22mmaybe[24m). - -[1mEXAMPLE[0m - #include <stdio.h> - #include <string.h> - #include <getarg.h> - - char *source = "Ouagadougou"; - char *destination; - int weight; - int include_catalog = 1; - int help_flag; - - struct getargs args[] = { - { "source", 's', arg_string, &source, - "source of shippment", "city" }, - { "destination", 'd', arg_string, &destination, - "destination of shippment", "city" }, - { "weight", 'w', arg_integer, &weight, - "weight of shippment", "tons" }, - { "catalog", 'c', arg_negative_flag, &include_catalog, - "include product catalog" }, - { "help", 'h', arg_flag, &help_flag } - }; - - int num_args = sizeof(args) / sizeof(args[0]); /* number of elements in args */ - - const char *progname = "ship++"; - - int - main(int argc, char **argv) - { - int optind = 0; - if (getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, "stuff..."); - exit (1); - } - if (help_flag) { - arg_printusage(args, num_args, progname, "stuff..."); - exit (0); - } - if (destination == NULL) { - fprintf(stderr, "%s: must specify destination\n", progname); - exit(1); - } - if (strcmp(source, destination) == 0) { - fprintf(stderr, "%s: destination must be different from source\n"); - exit(1); - } - /* include more stuff here ... */ - exit(2); - } - - The output help output from this program looks like this: - - $ ship++ --help - Usage: ship++ [--source=city] [-s city] [--destination=city] [-d city] - [--weight=tons] [-w tons] [--no-catalog] [-c] [--help] [-h] stuff... - -s city, --source=city source of shippment - -d city, --destination=city destination of shippment - -w tons, --weight=tons weight of shippment - -c, --no-catalog include product catalog - -[1mBUGS[0m - It should be more flexible, so it would be possible to use other more - complicated option syntaxes, such as what ps(1), and tar(1), uses, or the - AFS model where you can skip the flag names as long as the options come - in the correct order. - - Options with multiple arguments should be handled better. - - Should be integrated with SL. - - It's very confusing that the struct you pass in is called getargS. - -[1mSEE ALSO[0m - getopt(3) - -ROKEN September 24, 1999 ROKEN diff --git a/lib/roken/getauxval.c b/lib/roken/getauxval.c new file mode 100644 index 000000000000..785b1618f2f7 --- /dev/null +++ b/lib/roken/getauxval.c @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2016 - 2017 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#ifdef HAVE_SYS_AUXV_H +#include <sys/auxv.h> +#endif + +#if defined(ENABLE_PTHREAD_SUPPORT) && defined(HAVE_PTHREAD_H) +#include <pthread.h> +#endif + +#include <errno.h> + +#include "roken.h" +#include "getauxval.h" + +int rk_injected_auxv = 0; /* shared with issuid() for testing */ +static int has_proc_auxv = 1; +static int proc_auxv_ret = 0; + +#if defined(ENABLE_PTHREAD_SUPPORT) && defined(HAVE_PTHREAD_H) +pthread_once_t readprocauxv_once = PTHREAD_ONCE_INIT; +#endif + +/* + * There's no standard maximum. + * + * At the time of this writing we observe some 20 or so auxv entries. + * If eventually that grows much larger then rk_getprocaux*() will see a + * truncated auxv. + */ +#define MAX_AUXV_COUNT 128 +static auxv_t auxv[MAX_AUXV_COUNT]; + +static void +do_readprocauxv(void) +{ + char *p = (void *)auxv; + ssize_t bytes = 0; + size_t sz = sizeof(auxv) - sizeof(auxv[0]); /* leave terminator */ + int save_errno = errno; + int fd; + + errno = 0; + memset(auxv, 0, sizeof(auxv)); /* terminates our copy */ + if ((fd = open("/proc/self/auxv", O_RDONLY)) == -1) { + if (errno == ENOENT) + has_proc_auxv = 0; + goto out; + } + + do { + if ((bytes = read(fd, p, sz)) > 0) { + sz -= bytes; + p += bytes; + } + } while (sz && ((bytes == -1 && errno == EINTR) || bytes > 0)); + +out: + proc_auxv_ret = errno; + if (fd != -1) + (void) close(fd); + if (sz == 0 && bytes > 0) + warnx("/proc/self/auxv has more entries than expected"); + errno = save_errno; + return; +} + +static int +readprocauxv(void) +{ +#if defined(ENABLE_PTHREAD_SUPPORT) && defined(HAVE_PTHREAD_H) + pthread_once(&readprocauxv_once, do_readprocauxv); +#else + do_readprocauxv(); +#endif + return proc_auxv_ret; +} + +/** + * Looks up an auxv entry in /proc/self/auxv. Preserves errno. + * + * @return a pointer to an auxv_t if found, else NULL. + */ +ROKEN_LIB_FUNCTION const auxv_t * ROKEN_LIB_CALL +rk_getauxv(unsigned long type) +{ + auxv_t *a; + + if (!has_proc_auxv || type > INT_MAX) + return NULL; + + if (readprocauxv() != 0) + return NULL; + + for (a = auxv; a - auxv < MAX_AUXV_COUNT; a++) { + if ((int)a->a_type == (int)type) + return a; + if (a->a_type == 0 && a->a_un.a_val == 0) + break; + } + return NULL; +} + +#ifdef HAVE_GETAUXVAL +static unsigned long +rk_getprocauxval(unsigned long type) +{ + const auxv_t *a = rk_getauxv(type); + + if (a == NULL) { + errno = ENOENT; + return 0; + } + return a->a_un.a_val; +} +#endif + +/** + * Like the nearly-standard getauxval(). If the auxval is not found + * returns zero and always sets errno to ENOENT. Otherwise if auxval is + * found it leaves errno as it was, even if the value is zero. + * + * @return The value of the ELF auxiliary value for the given type, or + * zero and sets errno to ENOENT. + */ +ROKEN_LIB_FUNCTION unsigned long ROKEN_LIB_CALL +rk_getauxval(unsigned long type) +{ +#ifdef HAVE_GETAUXVAL +#ifdef GETAUXVAL_SETS_ERRNO + if (rk_injected_auxv) + return rk_getprocauxval(type); + return getauxval(type); +#else + unsigned long ret; + unsigned long ret2; + static int getauxval_sets_errno = -1; + const auxv_t *a; + int save_errno = errno; + + if (rk_injected_auxv) + return rk_getprocauxval(type); + + errno = 0; + ret = getauxval(type); + if (ret != 0 || errno == ENOENT || getauxval_sets_errno == 1) { + if (ret != 0) + errno = save_errno; + else if (getauxval_sets_errno > 0 && errno == 0) + errno = save_errno; + return ret; + } + + if (getauxval_sets_errno == 0) { + errno = save_errno; + a = rk_getauxv(type); + if (a == NULL) { + errno = ENOENT; + return 0; + } + return a->a_un.a_val; + } + + /* + * We've called getauxval() and it returned 0, but we don't know if + * getauxval() sets errno = ENOENT when entries are not found. + * + * Attempt to detect whether getauxval() sets errno = ENOENT by + * calling it with what should be a bogus type. + */ + + errno = 0; + ret2 = getauxval(~type); + if (ret2 == 0 && errno == ENOENT) { + getauxval_sets_errno = 1; + errno = save_errno; + return ret; + } + + getauxval_sets_errno = 0; + errno = save_errno; + if ((a = rk_getauxv(type)) == NULL) { + errno = ENOENT; + return 0; + } + return a->a_un.a_val; +#endif +#else + const auxv_t *a; + + if ((a = rk_getauxv(type)) == NULL) { + errno = ENOENT; + return 0; + } + return a->a_un.a_val; +#endif +} + +/** + * *Internal* function for testing by injecting or overwriting an ELF + * auxiliary vector entry. + * + * @return zero on success or ENOSPC if there are too many ELF auxiliary + * entries. + */ +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_injectauxv(auxv_t *e) +{ + size_t i; + int ret; + + /* + * This function is racy, but as an internal function never meant to + * be called in a threaded program, we don't care. + */ + + if ((ret = readprocauxv()) != 0) + return ret; + + rk_injected_auxv = 1; + for (i = 0; i < MAX_AUXV_COUNT - 1 && auxv[i].a_type != 0; i++) { + /* e->a_type == 0 -> truncate auxv, delete all entries */ + if (auxv[i].a_type == e->a_type || e->a_type == 0) + break; + } + if (i == MAX_AUXV_COUNT - 1) + return ENOSPC; + auxv[i] = e[0]; + return 0; +} diff --git a/lib/roken/getauxval.h b/lib/roken/getauxval.h new file mode 100644 index 000000000000..3088f0cd49b0 --- /dev/null +++ b/lib/roken/getauxval.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2016 - 2017 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef RK_GETAUXVAL_H +#define RK_GETAUXVAL_H + +#include <config.h> + +#ifdef HAVE_SYS_AUXV_H +#include <sys/auxv.h> +#endif + +#ifdef HAVE_SYS_EXEC_ELF_H +#include <sys/exec_elf.h> +#endif + +#ifndef HAVE_AUXV_T +/* + * Illumos defines auxv_t per the ABI standards, but all other OSes seem + * to use { long; long; } instead, depends on sizeof(long) == + * sizeof(void *), and they do not define an auxv_t. + * + * sizeof(long) != sizeof(void *) on WIN64, but Windows doesn't have + * /proc/self/auxv anyways. Just in case we use uintptr_t. + */ +typedef struct rk_auxv { + uintptr_t a_type; + union { + uintptr_t a_val; + uintptr_t a_ptr; /* This would be void * */ + uintptr_t a_fnc; /* This would be void (*)(void) */ + } a_un; +} auxv_t; +#endif + +#ifdef __linux__ +/* + * Older glibcs have no <sys/auxv.h>, but do nonetheless have an ELF + * auxiliary vector, and with the values for these types that appear in + * <sys/auxv.h> in later versions. + * + * Note that Travis-CI still uses Ubuntu 14 for its Linux build + * environment, which has such an older glibc version. + */ +#ifndef AT_UID +#define AT_UID 11 +#endif +#ifndef AT_EUID +#define AT_EUID 12 +#endif +#ifndef AT_GID +#define AT_GID 13 +#endif +#ifndef AT_EGID +#define AT_EGID 14 +#endif +#ifndef AT_SECURE +#define AT_SECURE 23 +#endif +#endif + +#if __sun +#if !defined(AT_UID) && defined(AT_SUN_RUID) +#define AT_UID AT_SUN_RUID +#endif +#if !defined(AT_EUID) && defined(AT_SUN_UID) +#define AT_EUID AT_SUN_UID +#endif +#if !defined(AT_GID) && defined(AT_SUN_RGID) +#define AT_GID AT_SUN_RGID +#endif +#if !defined(AT_EGID) && defined(AT_SUN_GID) +#define AT_EGID AT_SUN_GID +#endif +#endif /* __sun */ + +/* NetBSD calls AT_UID AT_RUID. Everyone else calls it AT_UID. */ +#if defined(AT_EUID) && defined(AT_RUID) && !defined(AT_UID) +#define AT_UID AT_RUID +#endif +#if defined(AT_EGID) && defined(AT_RGID) && !defined(AT_GID) +#define AT_GID AT_RGID +#endif + +#if defined(AT_EUID) && defined(AT_UID) && !defined(AT_RUID) +#define AT_RUID AT_UID +#endif +#if defined(AT_EGID) && defined(AT_GID) && !defined(AT_RGID) +#define AT_RGID AT_GID +#endif + + +/* + * There are three different names for the type whose value is the path + * to the executable being run by the process. + */ +#if defined(AT_EXECFN) && !defined(AT_EXECPATH) +#define AT_EXECPATH AT_EXECFN +#endif +#if defined(AT_EXECFN) && !defined(AT_SUN_EXECNAME) +#define AT_SUN_EXECNAME AT_EXECFN +#endif +#if defined(AT_EXECPATH) && !defined(AT_EXECFN) +#define AT_EXECFN AT_EXECPATH +#endif +#if defined(AT_EXECPATH) && !defined(AT_SUN_EXECNAME) +#define AT_SUN_EXECNAME AT_EXECPATH +#endif +#if defined(AT_SUN_EXECNAME) && !defined(AT_EXECFN) +#define AT_EXECFN AT_SUN_EXECNAME +#endif +#if defined(AT_SUN_EXECNAME) && !defined(AT_EXECPATH) +#define AT_EXECPATH AT_SUN_EXECNAME +#endif + +/* We need this for part of the getauxval() brokenness detection below */ +#ifdef __GLIBC__ +#ifdef __GLIBC_PREREQ +#define HAVE_GLIBC_API_VERSION_SUPPORT(maj, min) __GLIBC_PREREQ(maj, min) +#else +#define HAVE_GLIBC_API_VERSION_SUPPORT(maj, min) \ + ((__GLIBC << 16) + GLIBC_MINOR >= ((maj) << 16) + (min)) +#endif + +/* + * Detect whether getauxval() is broken. + * + * Do change this check in order to manually test rk_getauxval() for + * older glibcs. + */ +#if HAVE_GLIBC_API_VERSION_SUPPORT(2, 19) +#define GETAUXVAL_SETS_ERRNO +/* #else it's broken */ +#endif +#endif + +ROKEN_LIB_FUNCTION const auxv_t * ROKEN_LIB_CALL + rk_getauxv(unsigned long type); + +ROKEN_LIB_FUNCTION unsigned long ROKEN_LIB_CALL + rk_getauxval(unsigned long); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL + rk_injectauxv(auxv_t *e); + +#endif /* RK_GETAUXVAL_H */ diff --git a/lib/roken/getcap.c b/lib/roken/getcap.c deleted file mode 100644 index a8dd94bef9a9..000000000000 --- a/lib/roken/getcap.c +++ /dev/null @@ -1,996 +0,0 @@ -/* $NetBSD: getcap.c,v 1.29 1999/03/29 09:27:29 abs Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Casey Leedom of Lawrence Livermore National Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <config.h> - -#include "roken.h" - -#include <sys/types.h> -#include <ctype.h> -#if defined(HAVE_DB_185_H) -#include <db_185.h> -#elif defined(HAVE_DB_H) -#include <db.h> -#endif -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#define BFRAG 1024 -#define ESC ('[' & 037) /* ASCII ESC */ -#define MAX_RECURSION 32 /* maximum getent recursion */ -#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */ - -#define RECOK (char)0 -#define TCERR (char)1 -#define SHADOW (char)2 - -static size_t topreclen; /* toprec length */ -static char *toprec; /* Additional record specified by cgetset() */ -static int gottoprec; /* Flag indicating retrieval of toprecord */ - -#ifdef USE_DB -static int cdbget (DB *, char **, const char *); -#endif -static int getent (char **, size_t *, char **, int, const char *, int, char *); -static int nfcmp (char *, char *); - - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetset(const char *ent); -ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL cgetcap(char *buf, const char *cap, int type); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **buf, char **db_array, const char *name); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetmatch(const char *buf, const char *name); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetclose(void); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *buf, const char *cap, char **str); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetustr(char *buf, const char *cap, char **str); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetnum(char *buf, const char *cap, long *num); -/* - * Cgetset() allows the addition of a user specified buffer to be added - * to the database array, in effect "pushing" the buffer on top of the - * virtual database. 0 is returned on success, -1 on failure. - */ -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -cgetset(const char *ent) -{ - const char *source, *check; - char *dest; - - if (ent == NULL) { - if (toprec) - free(toprec); - toprec = NULL; - topreclen = 0; - return (0); - } - topreclen = strlen(ent); - if ((toprec = malloc (topreclen + 1)) == NULL) { - errno = ENOMEM; - return (-1); - } - gottoprec = 0; - - source=ent; - dest=toprec; - while (*source) { /* Strip whitespace */ - *dest++ = *source++; /* Do not check first field */ - while (*source == ':') { - check=source+1; - while (*check && (isspace((unsigned char)*check) || - (*check=='\\' && isspace((unsigned char)check[1])))) - ++check; - if( *check == ':' ) - source=check; - else - break; - - } - } - *dest=0; - - return (0); -} - -/* - * Cgetcap searches the capability record buf for the capability cap with - * type `type'. A pointer to the value of cap is returned on success, NULL - * if the requested capability couldn't be found. - * - * Specifying a type of ':' means that nothing should follow cap (:cap:). - * In this case a pointer to the terminating ':' or NUL will be returned if - * cap is found. - * - * If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator) - * return NULL. - */ -ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL -cgetcap(char *buf, const char *cap, int type) -{ - char *bp; - const char *cp; - - bp = buf; - for (;;) { - /* - * Skip past the current capability field - it's either the - * name field if this is the first time through the loop, or - * the remainder of a field whose name failed to match cap. - */ - for (;;) - if (*bp == '\0') - return (NULL); - else - if (*bp++ == ':') - break; - - /* - * Try to match (cap, type) in buf. - */ - for (cp = cap; *cp == *bp && *bp != '\0'; cp++, bp++) - continue; - if (*cp != '\0') - continue; - if (*bp == '@') - return (NULL); - if (type == ':') { - if (*bp != '\0' && *bp != ':') - continue; - return(bp); - } - if (*bp != type) - continue; - bp++; - return (*bp == '@' ? NULL : bp); - } - /* NOTREACHED */ -} - -/* - * Cgetent extracts the capability record name from the NULL terminated file - * array db_array and returns a pointer to a malloc'd copy of it in buf. - * Buf must be retained through all subsequent calls to cgetcap, cgetnum, - * cgetflag, and cgetstr, but may then be free'd. 0 is returned on success, - * -1 if the requested record couldn't be found, -2 if a system error was - * encountered (couldn't open/read a file, etc.), and -3 if a potential - * reference loop is detected. - */ -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -cgetent(char **buf, char **db_array, const char *name) -{ - size_t dummy; - - return (getent(buf, &dummy, db_array, -1, name, 0, NULL)); -} - -/* - * Getent implements the functions of cgetent. If fd is non-negative, - * *db_array has already been opened and fd is the open file descriptor. We - * do this to save time and avoid using up file descriptors for tc= - * recursions. - * - * Getent returns the same success/failure codes as cgetent. On success, a - * pointer to a malloc'ed capability record with all tc= capabilities fully - * expanded and its length (not including trailing ASCII NUL) are left in - * *cap and *len. - * - * Basic algorithm: - * + Allocate memory incrementally as needed in chunks of size BFRAG - * for capability buffer. - * + Recurse for each tc=name and interpolate result. Stop when all - * names interpolated, a name can't be found, or depth exceeds - * MAX_RECURSION. - */ -static int -getent(char **cap, size_t *len, char **db_array, int fd, - const char *name, int depth, char *nfield) -{ - char *r_end, *rp = NULL, **db_p; /* pacify gcc */ - int myfd = 0, eof, foundit; - char *record; - int tc_not_resolved; - - /* - * Return with ``loop detected'' error if we've recursed more than - * MAX_RECURSION times. - */ - if (depth > MAX_RECURSION) - return (-3); - - /* - * Check if we have a top record from cgetset(). - */ - if (depth == 0 && toprec != NULL && cgetmatch(toprec, name) == 0) { - size_t tmplen = topreclen + BFRAG; - if ((record = malloc (tmplen)) == NULL) { - errno = ENOMEM; - return (-2); - } - (void)strlcpy(record, toprec, tmplen); - db_p = db_array; - rp = record + topreclen + 1; - r_end = rp + BFRAG; - goto tc_exp; - } - /* - * Allocate first chunk of memory. - */ - if ((record = malloc(BFRAG)) == NULL) { - errno = ENOMEM; - return (-2); - } - r_end = record + BFRAG; - foundit = 0; - /* - * Loop through database array until finding the record. - */ - - for (db_p = db_array; *db_p != NULL; db_p++) { - eof = 0; - - /* - * Open database if not already open. - */ - - if (fd >= 0) { - (void)lseek(fd, (off_t)0, SEEK_SET); - } else { -#ifdef USE_DB - char pbuf[_POSIX_PATH_MAX]; - char *cbuf; - size_t clen; - int retval; - DB *capdbp; - - (void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p); - if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0)) - != NULL) { - free(record); - retval = cdbget(capdbp, &record, name); - /* record is no longer for us to free here */ - if (retval < 0) { - /* no record available */ - (void)capdbp->close(capdbp); - return (retval); - } - /* save the data; close frees it */ - clen = strlen(record); - cbuf = malloc(clen + 1); - if (cbuf == NULL) - return (-2); - memmove(cbuf, record, clen + 1); - if (capdbp->close(capdbp) < 0) { - free(cbuf); - return (-2); - } - *len = clen; - *cap = cbuf; - return (retval); - } else -#endif - { - fd = open(*db_p, O_RDONLY, 0); - if (fd < 0) { - /* No error on unfound file. */ - continue; - } - myfd = 1; - } - } - /* - * Find the requested capability record ... - */ - { - char buf[BUFSIZ]; - char *b_end, *bp, *cp; - int c, slash; - - /* - * Loop invariants: - * There is always room for one more character in record. - * R_end always points just past end of record. - * Rp always points just past last character in record. - * B_end always points just past last character in buf. - * Bp always points at next character in buf. - * Cp remembers where the last colon was. - */ - b_end = buf; - bp = buf; - cp = 0; - slash = 0; - for (;;) { - - /* - * Read in a line implementing (\, newline) - * line continuation. - */ - rp = record; - for (;;) { - if (bp >= b_end) { - int n; - - n = read(fd, buf, sizeof(buf)); - if (n <= 0) { - if (myfd) - (void)close(fd); - if (n < 0) { - free(record); - return (-2); - } else { - fd = -1; - eof = 1; - break; - } - } - b_end = buf+n; - bp = buf; - } - - c = *bp++; - if (c == '\n') { - if (slash) { - slash = 0; - rp--; - continue; - } else - break; - } - if (slash) { - slash = 0; - cp = 0; - } - if (c == ':') { - /* - * If the field was `empty' (i.e. - * contained only white space), back up - * to the colon (eliminating the - * field). - */ - if (cp) - rp = cp; - else - cp = rp; - } else if (c == '\\') { - slash = 1; - } else if (c != ' ' && c != '\t') { - /* - * Forget where the colon was, as this - * is not an empty field. - */ - cp = 0; - } - *rp++ = c; - - /* - * Enforce loop invariant: if no room - * left in record buffer, try to get - * some more. - */ - if (rp >= r_end) { - u_int pos; - char *tmp; - size_t newsize; - - pos = rp - record; - newsize = r_end - record + BFRAG; - tmp = realloc(record, newsize); - if (tmp == NULL) { - errno = ENOMEM; - if (myfd) - (void)close(fd); - free(record); - return (-2); - } - record = tmp; - r_end = record + newsize; - rp = record + pos; - } - } - /* Eliminate any white space after the last colon. */ - if (cp) - rp = cp + 1; - /* Loop invariant lets us do this. */ - *rp++ = '\0'; - - /* - * If encountered eof check next file. - */ - if (eof) - break; - - /* - * Toss blank lines and comments. - */ - if (*record == '\0' || *record == '#') - continue; - - /* - * See if this is the record we want ... - */ - if (cgetmatch(record, name) == 0) { - if (nfield == NULL || !nfcmp(nfield, record)) { - foundit = 1; - break; /* found it! */ - } - } - } - } - if (foundit) - break; - } - - if (!foundit) { - free(record); - return (-1); - } - - /* - * Got the capability record, but now we have to expand all tc=name - * references in it ... - */ - tc_exp: { - char *newicap, *s; - size_t ilen, newilen; - int diff, iret, tclen; - char *icap, *scan, *tc, *tcstart, *tcend; - - /* - * Loop invariants: - * There is room for one more character in record. - * R_end points just past end of record. - * Rp points just past last character in record. - * Scan points at remainder of record that needs to be - * scanned for tc=name constructs. - */ - scan = record; - tc_not_resolved = 0; - for (;;) { - if ((tc = cgetcap(scan, "tc", '=')) == NULL) - break; - - /* - * Find end of tc=name and stomp on the trailing `:' - * (if present) so we can use it to call ourselves. - */ - s = tc; - for (;;) - if (*s == '\0') - break; - else - if (*s++ == ':') { - *(s - 1) = '\0'; - break; - } - tcstart = tc - 3; - tclen = s - tcstart; - tcend = s; - - iret = getent(&icap, &ilen, db_p, fd, tc, depth+1, - NULL); - newicap = icap; /* Put into a register. */ - newilen = ilen; - if (iret != 0) { - /* an error */ - if (iret < -1) { - if (myfd) - (void)close(fd); - free(record); - return (iret); - } - if (iret == 1) - tc_not_resolved = 1; - /* couldn't resolve tc */ - if (iret == -1) { - *(s - 1) = ':'; - scan = s - 1; - tc_not_resolved = 1; - continue; - - } - } - /* not interested in name field of tc'ed record */ - s = newicap; - for (;;) - if (*s == '\0') - break; - else - if (*s++ == ':') - break; - newilen -= s - newicap; - newicap = s; - - /* make sure interpolated record is `:'-terminated */ - s += newilen; - if (*(s-1) != ':') { - *s = ':'; /* overwrite NUL with : */ - newilen++; - } - - /* - * Make sure there's enough room to insert the - * new record. - */ - diff = newilen - tclen; - if (diff >= r_end - rp) { - u_int pos, tcpos, tcposend; - size_t newsize; - char *tmp; - - pos = rp - record; - newsize = r_end - record + diff + BFRAG; - tcpos = tcstart - record; - tcposend = tcend - record; - tmp = realloc(record, newsize); - if (tmp == NULL) { - errno = ENOMEM; - if (myfd) - (void)close(fd); - free(icap); - free(record); - return (-2); - } - record = tmp; - r_end = record + newsize; - rp = record + pos; - tcstart = record + tcpos; - tcend = record + tcposend; - } - - /* - * Insert tc'ed record into our record. - */ - s = tcstart + newilen; - memmove(s, tcend, (size_t)(rp - tcend)); - memmove(tcstart, newicap, newilen); - rp += diff; - free(icap); - - /* - * Start scan on `:' so next cgetcap works properly - * (cgetcap always skips first field). - */ - scan = s-1; - } - - } - /* - * Close file (if we opened it), give back any extra memory, and - * return capability, length and success. - */ - if (myfd) - (void)close(fd); - *len = rp - record - 1; /* don't count NUL */ - if (r_end > rp) { - char *tmp = realloc(record, (size_t)(rp - record)); - if (tmp == NULL) { - errno = ENOMEM; - free(record); - return (-2); - } - record = tmp; - } - - *cap = record; - if (tc_not_resolved) - return (1); - return (0); -} - -#ifdef USE_DB -static int -cdbget(DB *capdbp, char **bp, const char *name) -{ - DBT key; - DBT data; - - /* LINTED key is not modified */ - key.data = (char *)name; - key.size = strlen(name); - - for (;;) { - /* Get the reference. */ - switch(capdbp->get(capdbp, &key, &data, 0)) { - case -1: - return (-2); - case 1: - return (-1); - } - - /* If not an index to another record, leave. */ - if (((char *)data.data)[0] != SHADOW) - break; - - key.data = (char *)data.data + 1; - key.size = data.size - 1; - } - - *bp = (char *)data.data + 1; - return (((char *)(data.data))[0] == TCERR ? 1 : 0); -} -#endif /* USE_DB */ - -/* - * Cgetmatch will return 0 if name is one of the names of the capability - * record buf, -1 if not. - */ -int -cgetmatch(const char *buf, const char *name) -{ - const char *np, *bp; - - /* - * Start search at beginning of record. - */ - bp = buf; - for (;;) { - /* - * Try to match a record name. - */ - np = name; - for (;;) - if (*np == '\0') { - if (*bp == '|' || *bp == ':' || *bp == '\0') - return (0); - else - break; - } else - if (*bp++ != *np++) - break; - - /* - * Match failed, skip to next name in record. - */ - bp--; /* a '|' or ':' may have stopped the match */ - for (;;) - if (*bp == '\0' || *bp == ':') - return (-1); /* match failed totally */ - else - if (*bp++ == '|') - break; /* found next name */ - } -} - -static FILE *pfp; -static int slash; -static char **dbp; - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -cgetclose(void) -{ - if (pfp != NULL) { - (void)fclose(pfp); - pfp = NULL; - } - dbp = NULL; - gottoprec = 0; - slash = 0; - return(0); -} - -/* - * Cgetstr retrieves the value of the string capability cap from the - * capability record pointed to by buf. A pointer to a decoded, NUL - * terminated, malloc'd copy of the string is returned in the char * - * pointed to by str. The length of the string not including the trailing - * NUL is returned on success, -1 if the requested string capability - * couldn't be found, -2 if a system error was encountered (storage - * allocation failure). - */ -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -cgetstr(char *buf, const char *cap, char **str) -{ - u_int m_room; - const char *bp; - char *mp; - int len; - char *mem, *nmem; - - *str = NULL; - - /* - * Find string capability cap - */ - bp = cgetcap(buf, cap, '='); - if (bp == NULL) - return (-1); - - /* - * Conversion / storage allocation loop ... Allocate memory in - * chunks SFRAG in size. - */ - if ((mem = malloc(SFRAG)) == NULL) { - errno = ENOMEM; - return (-2); /* couldn't even allocate the first fragment */ - } - m_room = SFRAG; - mp = mem; - - while (*bp != ':' && *bp != '\0') { - /* - * Loop invariants: - * There is always room for one more character in mem. - * Mp always points just past last character in mem. - * Bp always points at next character in buf. - */ - if (*bp == '^') { - bp++; - if (*bp == ':' || *bp == '\0') - break; /* drop unfinished escape */ - *mp++ = *bp++ & 037; - } else if (*bp == '\\') { - bp++; - if (*bp == ':' || *bp == '\0') - break; /* drop unfinished escape */ - if ('0' <= *bp && *bp <= '7') { - int n, i; - - n = 0; - i = 3; /* maximum of three octal digits */ - do { - n = n * 8 + (*bp++ - '0'); - } while (--i && '0' <= *bp && *bp <= '7'); - *mp++ = n; - } - else switch (*bp++) { - case 'b': case 'B': - *mp++ = '\b'; - break; - case 't': case 'T': - *mp++ = '\t'; - break; - case 'n': case 'N': - *mp++ = '\n'; - break; - case 'f': case 'F': - *mp++ = '\f'; - break; - case 'r': case 'R': - *mp++ = '\r'; - break; - case 'e': case 'E': - *mp++ = ESC; - break; - case 'c': case 'C': - *mp++ = ':'; - break; - default: - /* - * Catches '\', '^', and - * everything else. - */ - *mp++ = *(bp-1); - break; - } - } else - *mp++ = *bp++; - m_room--; - - /* - * Enforce loop invariant: if no room left in current - * buffer, try to get some more. - */ - if (m_room == 0) { - size_t size = mp - mem; - - if ((nmem = realloc(mem, size + SFRAG)) == NULL) { - free(mem); - return (-2); - } - mem = nmem; - m_room = SFRAG; - mp = mem + size; - } - } - *mp++ = '\0'; /* loop invariant let's us do this */ - m_room--; - len = mp - mem - 1; - - /* - * Give back any extra memory and return value and success. - */ - if (m_room != 0) { - if ((nmem = realloc(mem, (size_t)(mp - mem))) == NULL) { - free(mem); - return (-2); - } - mem = nmem; - } - *str = mem; - return (len); -} - -/* - * Cgetustr retrieves the value of the string capability cap from the - * capability record pointed to by buf. The difference between cgetustr() - * and cgetstr() is that cgetustr does not decode escapes but rather treats - * all characters literally. A pointer to a NUL terminated malloc'd - * copy of the string is returned in the char pointed to by str. The - * length of the string not including the trailing NUL is returned on success, - * -1 if the requested string capability couldn't be found, -2 if a system - * error was encountered (storage allocation failure). - */ -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -cgetustr(char *buf, const char *cap, char **str) -{ - u_int m_room; - const char *bp; - char *mp; - int len; - char *mem; - - /* - * Find string capability cap - */ - if ((bp = cgetcap(buf, cap, '=')) == NULL) - return (-1); - - /* - * Conversion / storage allocation loop ... Allocate memory in - * chunks SFRAG in size. - */ - if ((mem = malloc(SFRAG)) == NULL) { - errno = ENOMEM; - return (-2); /* couldn't even allocate the first fragment */ - } - m_room = SFRAG; - mp = mem; - - while (*bp != ':' && *bp != '\0') { - /* - * Loop invariants: - * There is always room for one more character in mem. - * Mp always points just past last character in mem. - * Bp always points at next character in buf. - */ - *mp++ = *bp++; - m_room--; - - /* - * Enforce loop invariant: if no room left in current - * buffer, try to get some more. - */ - if (m_room == 0) { - size_t size = mp - mem; - - if ((mem = realloc(mem, size + SFRAG)) == NULL) - return (-2); - m_room = SFRAG; - mp = mem + size; - } - } - *mp++ = '\0'; /* loop invariant let's us do this */ - m_room--; - len = mp - mem - 1; - - /* - * Give back any extra memory and return value and success. - */ - if (m_room != 0) { - char *tmp = realloc(mem, (size_t)(mp - mem)); - if (tmp == NULL) { - free(mem); - return (-2); - } - mem = tmp; - } - *str = mem; - return (len); -} - -/* - * Cgetnum retrieves the value of the numeric capability cap from the - * capability record pointed to by buf. The numeric value is returned in - * the long pointed to by num. 0 is returned on success, -1 if the requested - * numeric capability couldn't be found. - */ -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -cgetnum(char *buf, const char *cap, long *num) -{ - long n; - int base, digit; - const char *bp; - - /* - * Find numeric capability cap - */ - bp = cgetcap(buf, cap, '#'); - if (bp == NULL) - return (-1); - - /* - * Look at value and determine numeric base: - * 0x... or 0X... hexadecimal, - * else 0... octal, - * else decimal. - */ - if (*bp == '0') { - bp++; - if (*bp == 'x' || *bp == 'X') { - bp++; - base = 16; - } else - base = 8; - } else - base = 10; - - /* - * Conversion loop ... - */ - n = 0; - for (;;) { - if ('0' <= *bp && *bp <= '9') - digit = *bp - '0'; - else if ('a' <= *bp && *bp <= 'f') - digit = 10 + *bp - 'a'; - else if ('A' <= *bp && *bp <= 'F') - digit = 10 + *bp - 'A'; - else - break; - - if (digit >= base) - break; - - n = n * base + digit; - bp++; - } - - /* - * Return value and success. - */ - *num = n; - return (0); -} - - -/* - * Compare name field of record. - */ -static int -nfcmp(char *nf, char *rec) -{ - char *cp, tmp; - int ret; - - for (cp = rec; *cp != ':'; cp++) - ; - - tmp = *(cp + 1); - *(cp + 1) = '\0'; - ret = strcmp(nf, rec); - *(cp + 1) = tmp; - - return (ret); -} diff --git a/lib/roken/getifaddrs-test.c b/lib/roken/getifaddrs-test.c index 8d0725a68f91..252763df0405 100644 --- a/lib/roken/getifaddrs-test.c +++ b/lib/roken/getifaddrs-test.c @@ -117,7 +117,7 @@ main(int argc, char **argv) } if (rk_SOCK_INIT()) - errx(1, "Couldn't initialize sockets. Err=%d\n", rk_SOCK_ERRNO); + errx(1, "Failed to initialize sockets (%s)", strerror(rk_SOCK_ERRNO)); ret = getifaddrs(&addrs); if (ret != 0) diff --git a/lib/roken/getifaddrs.c b/lib/roken/getifaddrs.c index cc949b0b1a89..3d5584adf087 100644 --- a/lib/roken/getifaddrs.c +++ b/lib/roken/getifaddrs.c @@ -53,6 +53,11 @@ struct mbuf; #include <ifaddrs.h> +#ifdef HAVE_IFADDRS_H +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +rk_freeifaddrs(struct ifaddrs *ifp); +#endif + #ifdef __hpux #define lifconf if_laddrconf #define lifc_len iflc_len @@ -759,7 +764,7 @@ rk_getifaddrs(struct ifaddrs **ifap) } if (ifamap.address_len != ifamap.local_len || (ifamap.address != NULL && - memcmp(ifamap.address, ifamap.local, ifamap.address_len))) { + memcmp(ifamap.address, ifamap.local, ifamap.address_len) != 0)) { /* p2p; address is peer and local is ours */ ifamap.broadcast = ifamap.address; ifamap.broadcast_len = ifamap.address_len; @@ -853,7 +858,7 @@ rk_getifaddrs(struct ifaddrs **ifap) return 0; } -void ROKEN_LIB_FUNCTION +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_freeifaddrs(struct ifaddrs *ifp) { /* AF_NETLINK method uses a single allocation for all interfaces */ diff --git a/lib/roken/getipnodebyaddr.c b/lib/roken/getipnodebyaddr.c index 7d4095f1d840..afebe9149500 100644 --- a/lib/roken/getipnodebyaddr.c +++ b/lib/roken/getipnodebyaddr.c @@ -41,7 +41,7 @@ */ ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL -getipnodebyaddr (const void *src, size_t len, int af, int *error_num) +rk_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { struct hostent *tmp; diff --git a/lib/roken/getipnodebyname.c b/lib/roken/getipnodebyname.c index 2ff282707c23..ee430c76eb65 100644 --- a/lib/roken/getipnodebyname.c +++ b/lib/roken/getipnodebyname.c @@ -45,7 +45,7 @@ static int h_errno = NO_RECOVERY; */ ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL -getipnodebyname (const char *name, int af, int flags, int *error_num) +rk_getipnodebyname(const char *name, int af, int flags, int *error_num) { struct hostent *tmp; diff --git a/lib/roken/getnameinfo.c b/lib/roken/getnameinfo.c index b23ad01ebdd9..9d118600f264 100644 --- a/lib/roken/getnameinfo.c +++ b/lib/roken/getnameinfo.c @@ -92,10 +92,10 @@ doit (int af, */ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -getnameinfo(const struct sockaddr *sa, socklen_t salen, - char *host, size_t hostlen, - char *serv, size_t servlen, - int flags) +rk_getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, + char *serv, size_t servlen, + int flags) { switch (sa->sa_family) { #ifdef HAVE_IPV6 diff --git a/lib/roken/gettimeofday.c b/lib/roken/gettimeofday.c index a53b96f4f525..918b6f686b5f 100644 --- a/lib/roken/gettimeofday.c +++ b/lib/roken/gettimeofday.c @@ -37,6 +37,10 @@ #ifdef _WIN32 +typedef BOOL (WINAPI *LPFN_GETSYSTEMTIME) (LPFILETIME); + +static LPFN_GETSYSTEMTIME lpGetSystemTime = NULL; + ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL gettimeofday (struct timeval *tp, void *ignore) { @@ -44,7 +48,20 @@ gettimeofday (struct timeval *tp, void *ignore) ULARGE_INTEGER li; ULONGLONG ull; - GetSystemTimeAsFileTime(&ft); + if (lpGetSystemTime == NULL) { + HANDLE h1; + LPFN_GETSYSTEMTIME fn; + + h1 = GetModuleHandle(TEXT("kernel32.dll")); /* no refcount increase */ + fn = (LPFN_GETSYSTEMTIME)GetProcAddress(h1, + "GetSystemTimePreciseAsFileTime"); + if (fn == NULL) + fn = (LPFN_GETSYSTEMTIME)GetProcAddress(h1, + "GetSystemTimeAsFileTime"); + lpGetSystemTime = fn; + } + + lpGetSystemTime(&ft); li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; ull = li.QuadPart; @@ -57,7 +74,6 @@ gettimeofday (struct timeval *tp, void *ignore) return 0; } - #else /* diff --git a/lib/roken/getuserinfo.c b/lib/roken/getuserinfo.c new file mode 100644 index 000000000000..09f4c73155a2 --- /dev/null +++ b/lib/roken/getuserinfo.c @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2017 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> +#include "roken.h" + +#ifdef WIN32 +#include <Shlobj.h> // need to include definitions of constants +#define SECURITY_WIN32 +#include <security.h> +#else +#include <sys/types.h> +#include <pwd.h> +#include <unistd.h> +#endif + +/** + * Returns the user's SHELL. + */ +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_shell(char *shell, size_t shellsz) +{ + char *p; + +#ifndef WIN32 +#ifdef HAVE_GETPWNAM_R + size_t buflen = 2048; + + if (sysconf(_SC_GETPW_R_SIZE_MAX) > 0) + buflen = sysconf(_SC_GETPW_R_SIZE_MAX); +#endif + + if (issuid()) + return "/bin/sh"; + + p = secure_getenv("SHELL"); + if (p != NULL && p[0] != '\0') { + if (strlcpy(shell, p, shellsz) < shellsz) + return shell; + errno = ERANGE; + return NULL; + } + +#ifdef HAVE_GETPWNAM_R + { + struct passwd pwd; + struct passwd *pwdp; + char buf[buflen]; + char user[128]; + const char *username = roken_get_username(user, sizeof(user)); + + if (username && + getpwnam_r(username, &pwd, buf, buflen, &pwdp) == 0 && + pwdp != NULL && pwdp->pw_shell != NULL) { + if (strlcpy(shell, pwdp->pw_shell, shellsz) < shellsz) + return shell; + errno = ERANGE; + return NULL; + } + } +#endif + errno = 0; + return "/bin/sh"; +#else + /* Windows */ + p = getenv("SHELL"); + if (p != NULL && p[0] != '\0') { + if (strlcpy(shell, p, shellsz) < shellsz) + return shell; + errno = ERANGE; + return NULL; + } + errno = 0; + return NULL; +#endif +} + +/** + * Returns the home directory. + */ +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_homedir(char *home, size_t homesz) +{ + char *p; + +#ifdef WIN32 + if (homesz < MAX_PATH) { + errno = ERANGE; + return NULL; + } + + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, + SHGFP_TYPE_CURRENT, home))) + return home; + + if ((p = getenv("HOMEDRIVE")) != NULL && p[0] != '\0') { + if (strlcpy(home, p, homesz) >= homesz) { + errno = ERANGE; + return NULL; + } + if ((p = getenv("HOMEPATH")) != NULL) { + if (strlcat(home, p, homesz) < homesz) + return home; + errno = ERANGE; + return NULL; + } + return home; + } + HEIM_FALLTHROUGH; +#else +#ifdef HAVE_GETPWNAM_R + size_t buflen = 2048; + + if (sysconf(_SC_GETPW_R_SIZE_MAX) > 0) + buflen = sysconf(_SC_GETPW_R_SIZE_MAX); +#endif + + if (issuid()) { + errno = 0; + return NULL; + } + + p = secure_getenv("HOME"); + if (p != NULL && p[0] != '\0') { + if (strlcpy(home, p, homesz) < homesz) + return home; + errno = ERANGE; + return NULL; + } + +#ifdef HAVE_GETPWNAM_R + { + char user[128]; + const char *username = roken_get_username(user, sizeof(user)); + struct passwd pwd; + struct passwd *pwdp; + char buf[buflen]; + + if (username && + getpwnam_r(username, &pwd, buf, buflen, &pwdp) == 0 && + pwdp != NULL && pwdp->pw_dir != NULL) { + if (strlcpy(home, pwdp->pw_dir, homesz) < homesz) + return home; + errno = ERANGE; + return NULL; + } + } +#endif +#endif + errno = 0; + return NULL; +} + +/** + * Returns the home directory on Unix, or the AppData directory on + * Windows. + */ +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_appdatadir(char *appdata, size_t appdatasz) +{ +#ifdef WIN32 + char *p; +#endif + +#ifndef WIN32 + return roken_get_homedir(appdata, appdatasz); +#else + if (appdatasz < MAX_PATH) { + errno = ERANGE; + return NULL; + } + + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, + SHGFP_TYPE_CURRENT, appdata))) + return appdata; + + if ((p = getenv("APPDATA")) != NULL && p[0] != '\0') { + if (strlcpy(appdata, p, appdatasz) < appdatasz) + return appdata; + errno = ERANGE; + return NULL; + } + + errno = 0; + return NULL; +#endif +} + +/** + * Return a bare username. This is used for, e.g., constructing default + * principal names. + * + * On POSIX systems, if the caller is not set-uid-like, then this will return + * the value of the USER or LOGNAME environment variables (in that order of + * preference), else the username found by looking up the effective UID. + */ +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_username(char *user, size_t usersz) +{ + char *p; + +#ifdef WIN32 + ULONG sz = usersz; + + if (GetUserNameEx(NameSamCompatible, user, &sz)) { + /* + * There's no EXTENDED_NAME_FORMAT for "bare username". We we + * have to parse one. + */ + p = strchr(user, '\\'); + if (p != NULL) { + p++; + memmove(user, p, strlen(p) + 1); + } + return user; + } else { + DWORD err = GetLastError(); + if (err == ERROR_MORE_DATA) { + errno = ERANGE; + return NULL; + } + /* %USERNAME% is generally bare */ + p = getenv("USERNAME"); + if (p != NULL && p[0] != '\0') { + if (strchr(p, '\\') != NULL) + p = strchr(p, '\\') + 1; + if (strlcpy(user, p, usersz) < usersz) + return user; + errno = ERANGE; + return NULL; + } + } +#else +#ifdef HAVE_GETPWUID_R + size_t buflen = 2048; + + if (sysconf(_SC_GETPW_R_SIZE_MAX) > 0) + buflen = sysconf(_SC_GETPW_R_SIZE_MAX); +#endif + + p = secure_getenv("USER"); + if (p == NULL || p[0] == '\0') + p = secure_getenv("LOGNAME"); + if (p != NULL && p[0] != '\0') { + if (strlcpy(user, p, usersz) < usersz) + return user; + errno = ERANGE; + return NULL; + } + +#ifdef HAVE_GETPWUID_R + { + struct passwd pwd; + struct passwd *pwdp; + char buf[buflen]; + + if (getpwuid_r(getuid(), &pwd, buf, buflen, &pwdp) == 0 && + pwdp != NULL && pwdp->pw_name != NULL) { + if (strlcpy(user, pwdp->pw_name, usersz) < usersz) + return user; + errno = ERANGE; + return NULL; + } + } +#endif +#endif + errno = 0; + return NULL; +} + +/** + * Return a bare username. This is used for, e.g., constructing default + * principal names. + * + * On POSIX systems this returns the name recorded in the system as currently + * logged in on the current terminal. + */ +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_loginname(char *user, size_t usersz) +{ +#ifdef WIN32 + return roken_get_username(user, usersz); +#else +#ifdef HAVE_GETLOGIN_R + if ((errno = getlogin_r(user, usersz)) == 0) + return user; + if (errno != ENOENT) + return NULL; +#else +#ifdef HAVE_GETLOGIN + if ((p = getlogin()) != NULL && p[0] != '\0') { + if (strlcpy(user, p, usersz) < usersz) + return user; + errno = ERANGE; + return NULL; + } + if (errno != ENOENT) + return NULL; +#endif +#endif + errno = 0; + return NULL; +#endif +} diff --git a/lib/roken/getxxyyy.c b/lib/roken/getxxyyy.c deleted file mode 100644 index 25ce38b3e228..000000000000 --- a/lib/roken/getxxyyy.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2011 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <config.h> - -#include "roken.h" - -#ifdef TEST_GETXXYYY -#undef rk_getpwnam_r - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -rk_getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); -#endif - -#if !defined(POSIX_GETPWNAM_R) || defined(TEST_GETXXYYY) - -/* - * At least limit the race between threads - */ - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -rk_getpwnam_r(const char *name, struct passwd *pwd, char *buffer, - size_t bufsize, struct passwd **result) -{ - struct passwd *p; - size_t slen; - - *result = NULL; - - p = getpwnam(name); - if(p == NULL) - return (errno = ENOENT); - - memset(pwd, 0, sizeof(*pwd)); - -#define APPEND(el) \ -do { \ - slen = strlen(p->el) + 1; \ - if (slen > bufsize) return (errno = ENOMEM); \ - memcpy(buffer, p->el, slen); \ - pwd->el = buffer; \ - buffer += slen; \ - bufsize -= slen; \ -} while(0) - - APPEND(pw_name); - if (p->pw_passwd) - APPEND(pw_name); - pwd->pw_uid = p->pw_uid; - pwd->pw_gid = p->pw_gid; - APPEND(pw_gecos); - APPEND(pw_dir); - APPEND(pw_shell); - - *result = pwd; - - return 0; -} - -#endif /* POSIX_GETPWNAM_R */ - -#ifdef TEST_GETXXYYY - -#include <err.h> - -int verbose_flag = 0; - -static void -print_result(struct passwd *p) -{ - if (!verbose_flag) - return; - printf("%s\n", p->pw_name); - printf("%d\n", (int)p->pw_uid); - printf("%s\n", p->pw_shell); - printf("%s\n", p->pw_dir); -} - -int -main(int argc, char **argv) -{ - struct passwd pwd, *result; - char buf[1024]; - int ret; - const char *user; - - user = getenv("USER"); - if (!user) - user = "root"; - - ret = rk_getpwnam_r(user, &pwd, buf, sizeof(buf), &result); - if (ret) - errx(1, "rk_getpwnam_r"); - print_result(result); - - ret = rk_getpwnam_r(user, &pwd, buf, 1, &result); - if (ret == 0) - errx(1, "rk_getpwnam_r too small buf"); - - ret = rk_getpwnam_r("no-user-here-promise", &pwd, buf, sizeof(buf), &result); - if (ret == 0) - errx(1, "rk_getpwnam_r no user"); - - return 0; -} - -#endif diff --git a/lib/roken/glob.c b/lib/roken/glob.c deleted file mode 100644 index 03bc2a4dd613..000000000000 --- a/lib/roken/glob.c +++ /dev/null @@ -1,848 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * glob(3) -- a superset of the one defined in POSIX 1003.2. - * - * The [!...] convention to negate a range is supported (SysV, Posix, ksh). - * - * Optional extra services, controlled by flags not defined by POSIX: - * - * GLOB_QUOTE: - * Escaping convention: \ inhibits any special meaning the following - * character might have (except \ at end of string is retained). - * GLOB_MAGCHAR: - * Set in gl_flags if pattern contained a globbing character. - * GLOB_NOMAGIC: - * Same as GLOB_NOCHECK, but it will only append pattern if it did - * not contain any magic characters. [Used in csh style globbing] - * GLOB_ALTDIRFUNC: - * Use alternately specified directory access functions. - * GLOB_TILDE: - * expand ~user/foo to the /home/dir/of/user/foo - * GLOB_BRACE: - * expand {1,2}{a,b} to 1a 1b 2a 2b - * gl_matchc: - * Number of matches in the current invocation of glob. - */ - -#include <config.h> - -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#include <ctype.h> -#ifdef HAVE_DIRENT_H -#include <dirent.h> -#endif -#include <errno.h> -#ifdef HAVE_PWD_H -#include <pwd.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif - -#include "glob.h" -#include "roken.h" - -#ifndef ARG_MAX -#define ARG_MAX _POSIX_ARG_MAX -#endif - -#define CHAR_DOLLAR '$' -#define CHAR_DOT '.' -#define CHAR_EOS '\0' -#define CHAR_LBRACKET '[' -#define CHAR_NOT '!' -#define CHAR_QUESTION '?' -#define CHAR_QUOTE '\\' -#define CHAR_RANGE '-' -#define CHAR_RBRACKET ']' -#define CHAR_SEP '/' -#define CHAR_STAR '*' -#define CHAR_TILDE '~' -#define CHAR_UNDERSCORE '_' -#define CHAR_LBRACE '{' -#define CHAR_RBRACE '}' -#define CHAR_SLASH '/' -#define CHAR_COMMA ',' - -#ifndef DEBUG - -#define M_QUOTE 0x8000 -#define M_PROTECT 0x4000 -#define M_MASK 0xffff -#define M_ASCII 0x00ff - -typedef u_short Char; - -#else - -#define M_QUOTE 0x80 -#define M_PROTECT 0x40 -#define M_MASK 0xff -#define M_ASCII 0x7f - -typedef char Char; - -#endif - - -#define CHAR(c) ((Char)((c)&M_ASCII)) -#define META(c) ((Char)((c)|M_QUOTE)) -#define M_ALL META('*') -#define M_END META(']') -#define M_NOT META('!') -#define M_ONE META('?') -#define M_RNG META('-') -#define M_SET META('[') -#define ismeta(c) (((c)&M_QUOTE) != 0) - - -static int compare (const void *, const void *); -static void g_Ctoc (const Char *, char *); -static int g_lstat (Char *, struct stat *, glob_t *); -static DIR *g_opendir (Char *, glob_t *); -static Char *g_strchr (const Char *, int); -#ifdef notdef -static Char *g_strcat (Char *, const Char *); -#endif -static int g_stat (Char *, struct stat *, glob_t *); -static int glob0 (const Char *, glob_t *); -static int glob1 (Char *, glob_t *, size_t *); -static int glob2 (Char *, Char *, Char *, glob_t *, size_t *); -static int glob3 (Char *, Char *, Char *, Char *, glob_t *, size_t *); -static int globextend (const Char *, glob_t *, size_t *); -static const Char * globtilde (const Char *, Char *, glob_t *); -static int globexp1 (const Char *, glob_t *); -static int globexp2 (const Char *, const Char *, glob_t *, int *); -static int match (Char *, Char *, Char *); -#ifdef DEBUG -static void qprintf (const char *, Char *); -#endif - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -glob(const char *pattern, - int flags, - int (*errfunc)(const char *, int), - glob_t *pglob) -{ - const u_char *patnext; - int c; - Char *bufnext, *bufend, patbuf[MaxPathLen+1]; - - patnext = (const u_char *) pattern; - if (!(flags & GLOB_APPEND)) { - pglob->gl_pathc = 0; - pglob->gl_pathv = NULL; - if (!(flags & GLOB_DOOFFS)) - pglob->gl_offs = 0; - } - pglob->gl_flags = flags & ~GLOB_MAGCHAR; - pglob->gl_errfunc = errfunc; - pglob->gl_matchc = 0; - - bufnext = patbuf; - bufend = bufnext + MaxPathLen; - if (flags & GLOB_QUOTE) { - /* Protect the quoted characters. */ - while (bufnext < bufend && (c = *patnext++) != CHAR_EOS) - if (c == CHAR_QUOTE) { - if ((c = *patnext++) == CHAR_EOS) { - c = CHAR_QUOTE; - --patnext; - } - *bufnext++ = c | M_PROTECT; - } - else - *bufnext++ = c; - } - else - while (bufnext < bufend && (c = *patnext++) != CHAR_EOS) - *bufnext++ = c; - *bufnext = CHAR_EOS; - - if (flags & GLOB_BRACE) - return globexp1(patbuf, pglob); - else - return glob0(patbuf, pglob); -} - -/* - * Expand recursively a glob {} pattern. When there is no more expansion - * invoke the standard globbing routine to glob the rest of the magic - * characters - */ -static int globexp1(const Char *pattern, glob_t *pglob) -{ - const Char* ptr = pattern; - int rv; - - /* Protect a single {}, for find(1), like csh */ - if (pattern[0] == CHAR_LBRACE && pattern[1] == CHAR_RBRACE && pattern[2] == CHAR_EOS) - return glob0(pattern, pglob); - - while ((ptr = (const Char *) g_strchr(ptr, CHAR_LBRACE)) != NULL) - if (!globexp2(ptr, pattern, pglob, &rv)) - return rv; - - return glob0(pattern, pglob); -} - - -/* - * Recursive brace globbing helper. Tries to expand a single brace. - * If it succeeds then it invokes globexp1 with the new pattern. - * If it fails then it tries to glob the rest of the pattern and returns. - */ -static int globexp2(const Char *ptr, const Char *pattern, - glob_t *pglob, int *rv) -{ - int i; - Char *lm, *ls; - const Char *pe, *pm, *pl; - Char patbuf[MaxPathLen + 1]; - - /* copy part up to the brace */ - for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++) - continue; - ls = lm; - - /* Find the balanced brace */ - for (i = 0, pe = ++ptr; *pe; pe++) - if (*pe == CHAR_LBRACKET) { - /* Ignore everything between [] */ - for (pm = pe++; *pe != CHAR_RBRACKET && *pe != CHAR_EOS; pe++) - continue; - if (*pe == CHAR_EOS) { - /* - * We could not find a matching CHAR_RBRACKET. - * Ignore and just look for CHAR_RBRACE - */ - pe = pm; - } - } - else if (*pe == CHAR_LBRACE) - i++; - else if (*pe == CHAR_RBRACE) { - if (i == 0) - break; - i--; - } - - /* Non matching braces; just glob the pattern */ - if (i != 0 || *pe == CHAR_EOS) { - *rv = glob0(patbuf, pglob); - return 0; - } - - for (i = 0, pl = pm = ptr; pm <= pe; pm++) - switch (*pm) { - case CHAR_LBRACKET: - /* Ignore everything between [] */ - for (pl = pm++; *pm != CHAR_RBRACKET && *pm != CHAR_EOS; pm++) - continue; - if (*pm == CHAR_EOS) { - /* - * We could not find a matching CHAR_RBRACKET. - * Ignore and just look for CHAR_RBRACE - */ - pm = pl; - } - break; - - case CHAR_LBRACE: - i++; - break; - - case CHAR_RBRACE: - if (i) { - i--; - break; - } - /* FALLTHROUGH */ - case CHAR_COMMA: - if (i && *pm == CHAR_COMMA) - break; - else { - /* Append the current string */ - for (lm = ls; (pl < pm); *lm++ = *pl++) - continue; - /* - * Append the rest of the pattern after the - * closing brace - */ - for (pl = pe + 1; (*lm++ = *pl++) != CHAR_EOS;) - continue; - - /* Expand the current pattern */ -#ifdef DEBUG - qprintf("globexp2:", patbuf); -#endif - *rv = globexp1(patbuf, pglob); - - /* move after the comma, to the next string */ - pl = pm + 1; - } - break; - - default: - break; - } - *rv = 0; - return 0; -} - - - -/* - * expand tilde from the passwd file. - */ -static const Char * -globtilde(const Char *pattern, Char *patbuf, glob_t *pglob) -{ - struct passwd *pwd; - char *h; - const Char *p; - Char *b; - - if (*pattern != CHAR_TILDE || !(pglob->gl_flags & GLOB_TILDE)) - return pattern; - - /* Copy up to the end of the string or / */ - for (p = pattern + 1, h = (char *) patbuf; *p && *p != CHAR_SLASH; - *h++ = *p++) - continue; - - *h = CHAR_EOS; - - if (((char *) patbuf)[0] == CHAR_EOS) { - /* - * handle a plain ~ or ~/ by expanding $HOME - * first and then trying the password file - */ - if ((h = getenv("HOME")) == NULL) { - if ((pwd = k_getpwuid(getuid())) == NULL) - return pattern; - else - h = pwd->pw_dir; - } - } - else { - /* - * Expand a ~user - */ - if ((pwd = k_getpwnam((char*) patbuf)) == NULL) - return pattern; - else - h = pwd->pw_dir; - } - - /* Copy the home directory */ - for (b = patbuf; *h; *b++ = *h++) - continue; - - /* Append the rest of the pattern */ - while ((*b++ = *p++) != CHAR_EOS) - continue; - - return patbuf; -} - - -/* - * The main glob() routine: compiles the pattern (optionally processing - * quotes), calls glob1() to do the real pattern matching, and finally - * sorts the list (unless unsorted operation is requested). Returns 0 - * if things went well, nonzero if errors occurred. It is not an error - * to find no matches. - */ -static int -glob0(const Char *pattern, glob_t *pglob) -{ - const Char *qpatnext; - int c, ret, oldpathc; - Char *bufnext, patbuf[MaxPathLen+1]; - size_t limit = 0; - - qpatnext = globtilde(pattern, patbuf, pglob); - oldpathc = pglob->gl_pathc; - bufnext = patbuf; - - /* We don't need to check for buffer overflow any more. */ - while ((c = *qpatnext++) != CHAR_EOS) { - switch (c) { - case CHAR_LBRACKET: - c = *qpatnext; - if (c == CHAR_NOT) - ++qpatnext; - if (*qpatnext == CHAR_EOS || - g_strchr(qpatnext+1, CHAR_RBRACKET) == NULL) { - *bufnext++ = CHAR_LBRACKET; - if (c == CHAR_NOT) - --qpatnext; - break; - } - *bufnext++ = M_SET; - if (c == CHAR_NOT) - *bufnext++ = M_NOT; - c = *qpatnext++; - do { - *bufnext++ = CHAR(c); - if (*qpatnext == CHAR_RANGE && - (c = qpatnext[1]) != CHAR_RBRACKET) { - *bufnext++ = M_RNG; - *bufnext++ = CHAR(c); - qpatnext += 2; - } - } while ((c = *qpatnext++) != CHAR_RBRACKET); - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_END; - break; - case CHAR_QUESTION: - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_ONE; - break; - case CHAR_STAR: - pglob->gl_flags |= GLOB_MAGCHAR; - /* collapse adjacent stars to one, - * to avoid exponential behavior - */ - if (bufnext == patbuf || bufnext[-1] != M_ALL) - *bufnext++ = M_ALL; - break; - default: - *bufnext++ = CHAR(c); - break; - } - } - *bufnext = CHAR_EOS; -#ifdef DEBUG - qprintf("glob0:", patbuf); -#endif - - if ((ret = glob1(patbuf, pglob, &limit)) != 0) - return(ret); - - /* - * If there was no match we are going to append the pattern - * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified - * and the pattern did not contain any magic characters - * GLOB_NOMAGIC is there just for compatibility with csh. - */ - if (pglob->gl_pathc == oldpathc && - ((pglob->gl_flags & GLOB_NOCHECK) || - ((pglob->gl_flags & GLOB_NOMAGIC) && - !(pglob->gl_flags & GLOB_MAGCHAR)))) - return(globextend(pattern, pglob, &limit)); - else if (!(pglob->gl_flags & GLOB_NOSORT)) - qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, - pglob->gl_pathc - oldpathc, sizeof(char *), compare); - return(0); -} - -static int -compare(const void *p, const void *q) -{ - return(strcmp(*(char **)p, *(char **)q)); -} - -static int -glob1(Char *pattern, glob_t *pglob, size_t *limit) -{ - Char pathbuf[MaxPathLen+1]; - - /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */ - if (*pattern == CHAR_EOS) - return(0); - return(glob2(pathbuf, pathbuf, pattern, pglob, limit)); -} - -/* - * The functions glob2 and glob3 are mutually recursive; there is one level - * of recursion for each segment in the pattern that contains one or more - * meta characters. - */ - -#ifndef S_ISLNK -#if defined(S_IFLNK) && defined(S_IFMT) -#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) -#else -#define S_ISLNK(mode) 0 -#endif -#endif - -static int -glob2(Char *pathbuf, Char *pathend, Char *pattern, glob_t *pglob, - size_t *limit) -{ - struct stat sb; - Char *p, *q; - int anymeta; - - /* - * Loop over pattern segments until end of pattern or until - * segment with meta character found. - */ - for (anymeta = 0;;) { - if (*pattern == CHAR_EOS) { /* End of pattern? */ - *pathend = CHAR_EOS; - if (g_lstat(pathbuf, &sb, pglob)) - return(0); - - if (((pglob->gl_flags & GLOB_MARK) && - pathend[-1] != CHAR_SEP) && (S_ISDIR(sb.st_mode) - || (S_ISLNK(sb.st_mode) && - (g_stat(pathbuf, &sb, pglob) == 0) && - S_ISDIR(sb.st_mode)))) { - *pathend++ = CHAR_SEP; - *pathend = CHAR_EOS; - } - ++pglob->gl_matchc; - return(globextend(pathbuf, pglob, limit)); - } - - /* Find end of next segment, copy tentatively to pathend. */ - q = pathend; - p = pattern; - while (*p != CHAR_EOS && *p != CHAR_SEP) { - if (ismeta(*p)) - anymeta = 1; - *q++ = *p++; - } - - if (!anymeta) { /* No expansion, do next segment. */ - pathend = q; - pattern = p; - while (*pattern == CHAR_SEP) - *pathend++ = *pattern++; - } else /* Need expansion, recurse. */ - return(glob3(pathbuf, pathend, pattern, p, pglob, - limit)); - } - /* NOTREACHED */ -} - -static int -glob3(Char *pathbuf, Char *pathend, Char *pattern, Char *restpattern, - glob_t *pglob, size_t *limit) -{ - struct dirent *dp; - DIR *dirp; - int ret; - char buf[MaxPathLen]; - - /* - * The readdirfunc declaration can't be prototyped, because it is - * assigned, below, to two functions which are prototyped in glob.h - * and dirent.h as taking pointers to differently typed opaque - * structures. - */ - struct dirent *(*readdirfunc)(void *); - - *pathend = CHAR_EOS; - errno = 0; - - if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { - /* TODO: don't call for ENOENT or ENOTDIR? */ - if (pglob->gl_errfunc) { - g_Ctoc(pathbuf, buf); - if (pglob->gl_errfunc(buf, errno) || - pglob->gl_flags & GLOB_ERR) - return (GLOB_ABEND); - } - return(0); - } - - ret = 0; - - /* Search directory for matching names. */ - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - readdirfunc = pglob->gl_readdir; - else - readdirfunc = (struct dirent *(*)(void *))readdir; - while ((dp = (*readdirfunc)(dirp))) { - u_char *sc; - Char *dc; - - /* Initial CHAR_DOT must be matched literally. */ - if (dp->d_name[0] == CHAR_DOT && *pattern != CHAR_DOT) - continue; - for (sc = (u_char *) dp->d_name, dc = pathend; - (*dc++ = *sc++) != CHAR_EOS;) - continue; - if (!match(pathend, pattern, restpattern)) { - *pathend = CHAR_EOS; - continue; - } - ret = glob2(pathbuf, --dc, restpattern, pglob, limit); - if (ret) - break; - } - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - (*pglob->gl_closedir)(dirp); - else - closedir(dirp); - return(ret); -} - - -/* - * Extend the gl_pathv member of a glob_t structure to accomodate a new item, - * add the new item, and update gl_pathc. - * - * This assumes the BSD realloc, which only copies the block when its size - * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic - * behavior. - * - * Return 0 if new item added, error code if memory couldn't be allocated. - * - * Invariant of the glob_t structure: - * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and - * gl_pathv points to (gl_offs + gl_pathc + 1) items. - */ -static int -globextend(const Char *path, glob_t *pglob, size_t *limit) -{ - char **pathv; - int i; - size_t newsize, len; - char *copy; - const Char *p; - - newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); - pathv = pglob->gl_pathv ? - realloc(pglob->gl_pathv, newsize) : - malloc(newsize); - if (pathv == NULL) - return(GLOB_NOSPACE); - - if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { - /* first time around -- clear initial gl_offs items */ - pathv += pglob->gl_offs; - for (i = pglob->gl_offs; --i >= 0; ) - *--pathv = NULL; - } - pglob->gl_pathv = pathv; - - for (p = path; *p++;) - continue; - len = (size_t)(p - path); - *limit += len; - if ((copy = malloc(len)) != NULL) { - g_Ctoc(path, copy); - pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; - } - pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; - - if ((pglob->gl_flags & GLOB_LIMIT) && (newsize + *limit) >= ARG_MAX) { - errno = 0; - return(GLOB_NOSPACE); - } - - return(copy == NULL ? GLOB_NOSPACE : 0); -} - - -/* - * pattern matching function for filenames. Each occurrence of the * - * pattern causes a recursion level. - */ -static int -match(Char *name, Char *pat, Char *patend) -{ - int ok, negate_range; - Char c, k; - - while (pat < patend) { - c = *pat++; - switch (c & M_MASK) { - case M_ALL: - if (pat == patend) - return(1); - do - if (match(name, pat, patend)) - return(1); - while (*name++ != CHAR_EOS); - return(0); - case M_ONE: - if (*name++ == CHAR_EOS) - return(0); - break; - case M_SET: - ok = 0; - if ((k = *name++) == CHAR_EOS) - return(0); - if ((negate_range = ((*pat & M_MASK) == M_NOT)) != CHAR_EOS) - ++pat; - while (((c = *pat++) & M_MASK) != M_END) - if ((*pat & M_MASK) == M_RNG) { - if (c <= k && k <= pat[1]) - ok = 1; - pat += 2; - } else if (c == k) - ok = 1; - if (ok == negate_range) - return(0); - break; - default: - if (*name++ != c) - return(0); - break; - } - } - return(*name == CHAR_EOS); -} - -/* Free allocated data belonging to a glob_t structure. */ -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL -globfree(glob_t *pglob) -{ - int i; - char **pp; - - if (pglob->gl_pathv != NULL) { - pp = pglob->gl_pathv + pglob->gl_offs; - for (i = pglob->gl_pathc; i--; ++pp) - if (*pp) - free(*pp); - free(pglob->gl_pathv); - pglob->gl_pathv = NULL; - } -} - -static DIR * -g_opendir(Char *str, glob_t *pglob) -{ - char buf[MaxPathLen]; - - if (!*str) - strlcpy(buf, ".", sizeof(buf)); - else - g_Ctoc(str, buf); - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_opendir)(buf)); - - return(opendir(buf)); -} - -static int -g_lstat(Char *fn, struct stat *sb, glob_t *pglob) -{ - char buf[MaxPathLen]; - - g_Ctoc(fn, buf); - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_lstat)(buf, sb)); - return(lstat(buf, sb)); -} - -static int -g_stat(Char *fn, struct stat *sb, glob_t *pglob) -{ - char buf[MaxPathLen]; - - g_Ctoc(fn, buf); - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return((*pglob->gl_stat)(buf, sb)); - return(stat(buf, sb)); -} - -static Char * -g_strchr(const Char *str, int ch) -{ - do { - if (*str == ch) - return (Char *)str; - } while (*str++); - return (NULL); -} - -#ifdef notdef -static Char * -g_strcat(Char *dst, const Char *src) -{ - Char *sdst = dst; - - while (*dst++) - continue; - --dst; - while((*dst++ = *src++) != CHAR_EOS) - continue; - - return (sdst); -} -#endif - -static void -g_Ctoc(const Char *str, char *buf) -{ - char *dc; - - for (dc = buf; (*dc++ = *str++) != CHAR_EOS;) - continue; -} - -#ifdef DEBUG -static void -qprintf(const Char *str, Char *s) -{ - Char *p; - - printf("%s:\n", str); - for (p = s; *p; p++) - printf("%c", CHAR(*p)); - printf("\n"); - for (p = s; *p; p++) - printf("%c", *p & M_PROTECT ? '"' : ' '); - printf("\n"); - for (p = s; *p; p++) - printf("%c", ismeta(*p) ? '_' : ' '); - printf("\n"); -} -#endif diff --git a/lib/roken/glob.hin b/lib/roken/glob.hin deleted file mode 100644 index a4f16ce5e5d7..000000000000 --- a/lib/roken/glob.hin +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)glob.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _GLOB_H_ -#define _GLOB_H_ - -#ifndef ROKEN_LIB_FUNCTION -#ifdef _WIN32 -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL _stdcall -#else -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define glob_t rk_glob_t -#define glob rk_glob -#define globfree rk_globfree - -struct stat; -typedef struct { - int gl_pathc; /* Count of total paths so far. */ - int gl_matchc; /* Count of paths matching pattern. */ - int gl_offs; /* Reserved at beginning of gl_pathv. */ - int gl_flags; /* Copy of flags parameter to glob. */ - char **gl_pathv; /* List of paths matching pattern. */ - /* Copy of errfunc parameter to glob. */ - int (*gl_errfunc) (const char *, int); - - /* - * Alternate filesystem access methods for glob; replacement - * versions of closedir(3), readdir(3), opendir(3), stat(2) - * and lstat(2). - */ - void (*gl_closedir) (void *); - struct dirent *(*gl_readdir) (void *); - void *(*gl_opendir) (const char *); - int (*gl_lstat) (const char *, struct stat *); - int (*gl_stat) (const char *, struct stat *); -} glob_t; - -#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ -#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ -#define GLOB_ERR 0x0004 /* Return on error. */ -#define GLOB_MARK 0x0008 /* Append / to matching directories. */ -#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ -#define GLOB_NOSORT 0x0020 /* Don't sort. */ - -#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ -#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ -#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ -#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ -#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ -#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ -#define GLOB_LIMIT 0x1000 /* Limit memory used by matches to ARG_MAX */ - -#define GLOB_NOSPACE (-1) /* Malloc call failed. */ -#define GLOB_ABEND (-2) /* Unignored error. */ - -int ROKEN_LIB_FUNCTION -glob (const char *, int, int (*)(const char *, int), glob_t *); - -void ROKEN_LIB_FUNCTION -globfree (glob_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* !_GLOB_H_ */ diff --git a/lib/roken/hex-test.c b/lib/roken/hex-test.c index a81422e1f4a5..01f21c821d1a 100644 --- a/lib/roken/hex-test.c +++ b/lib/roken/hex-test.c @@ -43,7 +43,7 @@ main(int argc, char **argv) int numtest = 1; struct test { void *data; - size_t len; + ssize_t len; const char *result; } *t, tests[] = { { "", 0 , "" }, @@ -55,26 +55,35 @@ main(int argc, char **argv) { "abcdef", 6, "616263646566" }, { "abcdefg", 7, "61626364656667" }, { "=", 1, "3D" }, + /* Embedded NUL, non-ASCII / binary */ + { "\0\x01\x1a\xad\xf1\xff", 6, "00011AADF1FF" }, + /* Invalid encodings */ + { "", -1, "00.11AADF1FF" }, + { "", -1, "000x1AADF1FF" }, + { "", -1, "00011?ADF1FF" }, { NULL, 0, NULL } }; for(t = tests; t->data; t++) { + ssize_t len; char *str; - int len; - len = hex_encode(t->data, t->len, &str); - if(strcmp(str, t->result) != 0) { - fprintf(stderr, "failed test %d: %s != %s\n", numtest, - str, t->result); - numerr++; - } - free(str); + + if (t->len > -1) { + (void) hex_encode(t->data, t->len, &str); + if (strcmp(str, t->result) != 0) { + fprintf(stderr, "failed test %d: %s != %s\n", numtest, + str, t->result); + numerr++; + } + free(str); + } str = strdup(t->result); len = strlen(str); len = hex_decode(t->result, str, len); - if(len != t->len) { - fprintf(stderr, "failed test %d: len %lu != %lu\n", numtest, - (unsigned long)len, (unsigned long)t->len); + if (len != t->len) { + fprintf(stderr, "failed test %d: len %lu != %ld\n", numtest, + (long)len, (long)t->len); numerr++; - } else if(memcmp(str, t->data, t->len) != 0) { + } else if (t->len > -1 && memcmp(str, t->data, t->len) != 0) { fprintf(stderr, "failed test %d: data\n", numtest); numerr++; } diff --git a/lib/roken/hex.c b/lib/roken/hex.c index c66b324f7900..5cd202603f39 100644 --- a/lib/roken/hex.c +++ b/lib/roken/hex.c @@ -39,14 +39,15 @@ static const char hexchar[16] = "0123456789ABCDEF"; -static int +static inline int pos(char c) { - const char *p; - c = toupper((unsigned char)c); - for (p = hexchar; *p; p++) - if (*p == c) - return p - hexchar; + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'A' && c <= 'F') + return 10 + c - 'A'; + if (c >= 'a' && c <= 'f') + return 10 + c - 'a'; return -1; } @@ -57,13 +58,7 @@ hex_encode(const void *data, size_t size, char **str) size_t i; char *p; - /* check for overflow */ - if (size * 2 < size) { - *str = NULL; - return -1; - } - - p = malloc(size * 2 + 1); + p = calloc(size + 1, 2); if (p == NULL) { *str = NULL; return -1; @@ -86,6 +81,7 @@ hex_decode(const char *str, void *data, size_t len) size_t l; unsigned char *p = data; size_t i; + int d; l = strlen(str); @@ -94,11 +90,19 @@ hex_decode(const char *str, void *data, size_t len) return -1; if (l & 1) { - p[0] = pos(str[0]); + if ((d = pos(str[0])) == -1) + return -1; + p[0] = d; str++; p++; } - for (i = 0; i < l / 2; i++) - p[i] = pos(str[i * 2]) << 4 | pos(str[(i * 2) + 1]); + for (i = 0; i < l / 2; i++) { + if ((d = pos(str[i * 2])) == -1) + return -1; + p[i] = d << 4; + if ((d = pos(str[(i * 2) + 1])) == -1) + return -1; + p[i] |= d; + } return i + (l & 1); } diff --git a/lib/roken/ifaddrs.hin b/lib/roken/ifaddrs.hin index ef00b63bad6d..88963912362a 100644 --- a/lib/roken/ifaddrs.hin +++ b/lib/roken/ifaddrs.hin @@ -67,10 +67,10 @@ struct ifaddrs { #define ifa_broadaddr ifa_dstaddr #endif -int ROKEN_LIB_FUNCTION +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_getifaddrs(struct ifaddrs**); -void ROKEN_LIB_FUNCTION +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_freeifaddrs(struct ifaddrs*); #define getifaddrs(a) rk_getifaddrs(a) diff --git a/lib/roken/iruserok.c b/lib/roken/iruserok.c deleted file mode 100644 index 95f654681ec8..000000000000 --- a/lib/roken/iruserok.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 1983, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <config.h> - -#include <stdio.h> -#include <ctype.h> -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_NETINET_IN6_H -#include <netinet/in6.h> -#endif -#ifdef HAVE_NETINET6_IN6_H -#include <netinet6/in6.h> -#endif -#ifdef HAVE_RPCSVC_YPCLNT_H -#include <rpcsvc/ypclnt.h> -#endif - -#include "roken.h" - -int __check_rhosts_file = 1; -char *__rcmd_errstr = 0; - -/* - * Returns "true" if match, 0 if no match. - */ -static -int -__icheckhost(unsigned raddr, const char *lhost) -{ - struct hostent *hp; - u_long laddr; - char **pp; - - /* Try for raw ip address first. */ - if (isdigit((unsigned char)*lhost) - && (long)(laddr = inet_addr(lhost)) != -1) - return (raddr == laddr); - - /* Better be a hostname. */ - if ((hp = gethostbyname(lhost)) == NULL) - return (0); - - /* Spin through ip addresses. */ - for (pp = hp->h_addr_list; *pp; ++pp) - if (memcmp(&raddr, *pp, sizeof(u_long)) == 0) - return (1); - - /* No match. */ - return (0); -} - -/* - * Returns 0 if ok, -1 if not ok. - */ -static -int -__ivaliduser(FILE *hostf, unsigned raddr, const char *luser, - const char *ruser) -{ - char *user, *p; - int ch; - char buf[MaxHostNameLen + 128]; /* host + login */ - char hname[MaxHostNameLen]; - struct hostent *hp; - /* Presumed guilty until proven innocent. */ - int userok = 0, hostok = 0; -#ifdef HAVE_YP_GET_DEFAULT_DOMAIN - char *ypdomain; - - if (yp_get_default_domain(&ypdomain)) - ypdomain = NULL; -#else -#define ypdomain NULL -#endif - /* We need to get the damn hostname back for netgroup matching. */ - if ((hp = gethostbyaddr((char *)&raddr, - sizeof(u_long), - AF_INET)) == NULL) - return (-1); - strlcpy(hname, hp->h_name, sizeof(hname)); - - while (fgets(buf, sizeof(buf), hostf)) { - p = buf; - /* Skip lines that are too long. */ - if (strchr(p, '\n') == NULL) { - while ((ch = getc(hostf)) != '\n' && ch != EOF); - continue; - } - if (*p == '\n' || *p == '#') { - /* comment... */ - continue; - } - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { - if (isupper((unsigned char)*p)) - *p = tolower((unsigned char)*p); - p++; - } - if (*p == ' ' || *p == '\t') { - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - user = p; - while (*p != '\n' && *p != ' ' && - *p != '\t' && *p != '\0') - p++; - } else - user = p; - *p = '\0'; - /* - * Do +/- and +@/-@ checking. This looks really nasty, - * but it matches SunOS's behavior so far as I can tell. - */ - switch(buf[0]) { - case '+': - if (!buf[1]) { /* '+' matches all hosts */ - hostok = 1; - break; - } - if (buf[1] == '@') /* match a host by netgroup */ - hostok = innetgr((char *)&buf[2], - (char *)&hname, NULL, ypdomain); - else /* match a host by addr */ - hostok = __icheckhost(raddr,(char *)&buf[1]); - break; - case '-': /* reject '-' hosts and all their users */ - if (buf[1] == '@') { - if (innetgr((char *)&buf[2], - (char *)&hname, NULL, ypdomain)) - return(-1); - } else { - if (__icheckhost(raddr,(char *)&buf[1])) - return(-1); - } - break; - default: /* if no '+' or '-', do a simple match */ - hostok = __icheckhost(raddr, buf); - break; - } - switch(*user) { - case '+': - if (!*(user+1)) { /* '+' matches all users */ - userok = 1; - break; - } - if (*(user+1) == '@') /* match a user by netgroup */ - userok = innetgr(user+2, NULL, (char *)ruser, - ypdomain); - else /* match a user by direct specification */ - userok = !(strcmp(ruser, user+1)); - break; - case '-': /* if we matched a hostname, */ - if (hostok) { /* check for user field rejections */ - if (!*(user+1)) - return(-1); - if (*(user+1) == '@') { - if (innetgr(user+2, NULL, - (char *)ruser, ypdomain)) - return(-1); - } else { - if (!strcmp(ruser, user+1)) - return(-1); - } - } - break; - default: /* no rejections: try to match the user */ - if (hostok) - userok = !(strcmp(ruser,*user ? user : luser)); - break; - } - if (hostok && userok) - return(0); - } - return (-1); -} - -/* - * New .rhosts strategy: We are passed an ip address. We spin through - * hosts.equiv and .rhosts looking for a match. When the .rhosts only - * has ip addresses, we don't have to trust a nameserver. When it - * contains hostnames, we spin through the list of addresses the nameserver - * gives us and look for a match. - * - * Returns 0 if ok, -1 if not ok. - */ -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -iruserok(unsigned raddr, int superuser, const char *ruser, const char *luser) -{ - char *cp; - struct stat sbuf; - struct passwd *pwd; - FILE *hostf; - uid_t uid; - int first; - char pbuf[MaxPathLen]; - - first = 1; - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); -again: - if (hostf) { - if (__ivaliduser(hostf, raddr, luser, ruser) == 0) { - fclose(hostf); - return (0); - } - fclose(hostf); - } - if (first == 1 && (__check_rhosts_file || superuser)) { - first = 0; - if ((pwd = k_getpwnam((char*)luser)) == NULL) - return (-1); - snprintf (pbuf, sizeof(pbuf), "%s/.rhosts", pwd->pw_dir); - - /* - * Change effective uid while opening .rhosts. If root and - * reading an NFS mounted file system, can't read files that - * are protected read/write owner only. - */ - uid = geteuid(); - if (seteuid(pwd->pw_uid) < 0) - return (-1); - hostf = fopen(pbuf, "r"); - seteuid(uid); - - if (hostf == NULL) - return (-1); - /* - * If not a regular file, or is owned by someone other than - * user or root or if writeable by anyone but the owner, quit. - */ - cp = NULL; - if (lstat(pbuf, &sbuf) < 0) - cp = ".rhosts lstat failed"; - else if (!S_ISREG(sbuf.st_mode)) - cp = ".rhosts not regular file"; - else if (fstat(fileno(hostf), &sbuf) < 0) - cp = ".rhosts fstat failed"; - else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) - cp = "bad .rhosts owner"; - else if (sbuf.st_mode & (S_IWGRP|S_IWOTH)) - cp = ".rhosts writeable by other than owner"; - /* If there were any problems, quit. */ - if (cp) { - __rcmd_errstr = cp; - fclose(hostf); - return (-1); - } - goto again; - } - return (-1); -} diff --git a/lib/roken/issuid.c b/lib/roken/issuid.c index 7a77b3834461..b9b7440351c4 100644 --- a/lib/roken/issuid.c +++ b/lib/roken/issuid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 - 2001 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2017 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -40,176 +40,239 @@ #include <errno.h> #include "roken.h" +#include "getauxval.h" -/* NetBSD calls AT_UID AT_RUID. Everyone else calls it AT_UID. */ -#if defined(AT_EUID) && defined(AT_RUID) && !defined(AT_UID) -#define AT_UID AT_RUID -#endif -#if defined(AT_EGID) && defined(AT_RGID) && !defined(AT_GID) -#define AT_GID AT_RGID -#endif - -#ifdef __GLIBC__ -#ifdef __GLIBC_PREREQ -#define HAVE_GLIBC_API_VERSION_SUPPORT(maj, min) __GLIBC_PREREQ(maj, min) -#else -#define HAVE_GLIBC_API_VERSION_SUPPORT(maj, min) \ - ((__GLIBC << 16) + GLIBC_MINOR >= ((maj) << 16) + (min)) -#endif - -#if HAVE_GLIBC_API_VERSION_SUPPORT(2, 19) -#define GETAUXVAL_SETS_ERRNO -#endif -#endif - -#ifdef HAVE_GETAUXVAL -static unsigned long -rk_getauxval(unsigned long type) -{ - errno = 0; -#ifdef GETAUXVAL_SETS_ERRNO - return getauxval(type); -#else - unsigned long ret = getauxval(type); - - if (ret == 0) - errno = ENOENT; - return ret; -#endif -} -#define USE_RK_GETAUXVAL -#endif +extern int rk_injected_auxv; /** * Returns non-zero if the caller's process started as set-uid or * set-gid (and therefore the environment cannot be trusted). * + * As much as possible this implements the same functionality and + * semantics as OpenBSD's issetugid() (as opposed to FreeBSD's). + * + * Preserves errno. + * * @return Non-zero if the environment is not trusted. */ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void) { +#ifdef WIN32 + return 0; /* No set-id programs or anything like it on Windows */ +#else /* * We want to use issetugid(), but issetugid() is not the same on * all OSes. * - * On Illumos derivatives, OpenBSD, and Solaris issetugid() returns - * true IFF the program exec()ed was set-uid or set-gid. + * On OpenBSD (where issetugid() originated), Illumos derivatives, + * and Solaris, issetugid() returns true IFF the program exec()ed + * was set-uid or set-gid. + * + * FreeBSD departed from OpenBSD's issetugid() semantics, and other + * BSDs (NetBSD, DragonFly) and OS X adopted FreeBSD's. * - * On NetBSD and FreeBSD issetugid() returns true if the program - * exec()ed was set-uid or set-gid, or if the process has switched - * UIDs/GIDs or otherwise changed privileges or is a descendant of - * such a process and has not exec()ed since. + * FreeBSDs' issetugid() returns true if the program exec()ed was + * set-uid or set-gid, or if the process has switched UIDs/GIDs or + * otherwise changed privileges or is a descendant of such a process + * and has not exec()ed since. * - * What we want here is to know only if the program exec()ed was - * set-uid or set-gid, so we can decide whether to trust the - * enviroment variables. We don't care if this was a process that - * started as root and later changed UIDs/privs whatever: since it - * started out as privileged, it inherited an environment from a - * privileged pre-exec self, and so on, so the environment is - * trusted. + * The FreeBSD/NetBSD issetugid() does us no good because we _want_ + * to trust the environment when the process started life as + * non-set-uid root (or otherwise privileged). There's nothing + * about _dropping_ privileges (without having gained them first) + * that taints the environment. It's not like calling system(), + * say, might change the environment of the caller. * - * Therefore the FreeBSD/NetBSD issetugid() does us no good. + * We want OpenBSD's issetugid() semantics. * * Linux, meanwhile, has no issetugid() (at least glibc doesn't - * anyways). + * anyways) but has an equivalent: getauxval(AT_SECURE). + * + * To be really specific: we want getauxval(AT_SECURE) semantics + * because there may be ways in which a process might gain privilege + * at exec time other than by exec'ing a set-id program. * - * Systems that support ELF put an "auxilliary vector" on the stack - * prior to starting the RTLD, and this vector includes (optionally) - * information about the process' EUID, RUID, EGID, RGID, and so on - * at the time of exec(), which we can use to construct proper - * issetugid() functionality. + * Where we use getauxval(), we really use our getauxval(), the one + * that isn't broken the way glibc's used to be. Our getauxval() + * also works on more systems than actually provide one. * - * Where available, we use the ELF auxilliary vector as a fallback - * if issetugid() is not available. + * In order to avoid FreeBSD issetugid() semantics, where available, + * we use the ELF auxilliary vector to implement OpenBSD semantics + * before finally falling back on issetugid(). * - * All of this is as of late March 2015, and might become stale in - * the future. + * All of this is as of April 2017, and might become stale in the + * future. */ + static int we_are_suid = -1; /* Memoize; -1 == dunno */ + int save_errno = errno; +#if defined(AT_EUID) && defined(AT_UID) && defined(AT_EGID) && defined(AT_GID) + int seen = 0; +#endif -#ifdef USE_RK_GETAUXVAL - /* If we have getauxval(), use that */ + if (we_are_suid >= 0 && !rk_injected_auxv) + return we_are_suid; -#if (defined(AT_EUID) && defined(AT_UID) || (defined(AT_EGID) && defined(AT_GID))) - int seen = 0; +#ifdef AT_SECURE + errno = 0; + if (rk_getauxval(AT_SECURE) != 0) { + errno = save_errno; + return we_are_suid = 1; + } else if (errno == 0) { + errno = save_errno; + return we_are_suid = 0; + } + /* errno == ENOENT; AT_SECURE not found; fall through */ #endif -#if defined(AT_EUID) && defined(AT_UID) +#if defined(AT_EUID) && defined(AT_UID) && defined(AT_EGID) && defined(AT_GID) { unsigned long euid; unsigned long uid; + errno = 0; euid = rk_getauxval(AT_EUID); if (errno == 0) seen |= 1; + errno = 0; uid = rk_getauxval(AT_UID); if (errno == 0) seen |= 2; - if (euid != uid) - return 1; + if (euid != uid) { + errno = save_errno; + return we_are_suid = 1; + } } -#endif -#if defined(AT_EGID) && defined(AT_GID) + /* Check GIDs */ { unsigned long egid; unsigned long gid; + errno = 0; egid = rk_getauxval(AT_EGID); if (errno == 0) seen |= 4; + errno = 0; gid = rk_getauxval(AT_GID); if (errno == 0) seen |= 8; - if (egid != gid) - return 2; + if (egid != gid) { + errno = save_errno; + return we_are_suid = 1; + } } -#endif -#ifdef AT_SECURE - /* AT_SECURE is set if the program was set-id. */ - if (rk_getauxval(AT_SECURE) != 0) - return 1; + errno = save_errno; + if (seen == 15) + return we_are_suid = 0; #endif -#if (defined(AT_EUID) && defined(AT_UID) || (defined(AT_EGID) && defined(AT_GID))) - if (seen == 15) - return 0; +#if defined(HAVE_ISSETUGID) + /* If issetugid() == 0 then we're definitely OK then */ + if (issetugid() == 0) + return we_are_suid = 0; + /* issetugid() == 1 might have been a false positive; fall through */ #endif - /* rk_getauxval() does set errno */ - if (errno == 0) - return 0; +#ifdef AT_EXECFN /* - * Fall through if we have getauxval() but we didn't have (or don't - * know if we don't have) the aux entries that we needed. + * There's an auxval by which to find the path of the program this + * process exec'ed. + * + * We can stat() it. If the program did a chroot() and the chroot + * has a program with the same path but not set-uid/set-gid, of + * course, we lose here. But a) that's a bit of a stretch, b) + * there's not much more we can do here. + * + * Also, this is technically a TOCTOU race, though for set-id + * programs this is exceedingly unlikely to be an actual TOCTOU + * race. + * + * TODO We should really make sure that none of the path components of the + * execpath are symlinks. */ -#endif /* USE_RK_GETAUXVAL */ + { + unsigned long p = rk_getauxval(AT_EXECPATH); + struct stat st; + + if (p != 0 && *(const char *)p == '/' && + stat((const char *)p, &st) == 0) { + if ((st.st_mode & S_ISUID) || (st.st_mode & S_ISGID)) { + errno = save_errno; + return we_are_suid = 1; + } + errno = save_errno; + return we_are_suid = 0; + } + } + /* Fall through */ +#endif #if defined(HAVE_ISSETUGID) + errno = save_errno; + return we_are_suid = 1; +#else /* - * If we have issetugid(), use it. + * Paranoia: for extra safety we ought to default to returning 1. + * + * But who knows what that might break where users link statically + * (so no auxv), say. + * + * We'll check the actual real and effective IDs (as opposed to the + * ones at main() start time. * - * We may lose on some BSDs. This manifests as, for example, - * gss_store_cred() not honoring KRB5CCNAME. + * For now we stick to returning zero by default. We've been rather + * heroic above trying to find out if we're suid, and we're running + * on a rather old or uncool OS if we've gotten here. */ - return issetugid(); -#endif /* USE_RK_GETAUXVAL */ +#if defined(HAVE_GETRESUID) /* - * Paranoia: for extra safety we ought to default to returning 1. - * But who knows what that might break where users link statically - * and use a.out, say. Also, on Windows we should always return 0. + * If r/e/suid are all the same then chances are very good we did + * not start as set-uid. Though this could be a login program that + * started out as privileged and is calling Heimdal "as the user". * - * For now we stick to returning zero by default. + * Again, such a program would have to be statically linked to get + * here. */ + { + uid_t r, e, s; + if (getresuid(&r, &e, &s) == 0) { + if (r != e || r != s) { + errno = save_errno; + return we_are_suid = 1; + } + } + } +#endif +#if defined(HAVE_GETRESGID) + { + gid_t r, e, s; + if (getresgid(&r, &e, &s) == 0) { + if (r != e || r != s) { + errno = save_errno; + return we_are_suid = 1; + } + } + } +#endif +#if defined(HAVE_GETRESUID) && defined(HAVE_GETRESGID) + errno = save_errno; + return we_are_suid = 0; + +#else /* avoid compiler warnings about dead code */ #if defined(HAVE_GETUID) && defined(HAVE_GETEUID) if (getuid() != geteuid()) - return 1; + return we_are_suid = 1; #endif #if defined(HAVE_GETGID) && defined(HAVE_GETEGID) if (getgid() != getegid()) - return 2; + return we_are_suid = 1; #endif - return 0; + errno = save_errno; + return we_are_suid = 0; +#endif /* !defined(HAVE_GETRESUID) || !defined(HAVE_GETRESGID) */ +#endif /* !defined(HAVE_ISSETUGID) */ +#endif /* WIN32 */ } diff --git a/lib/roken/memmem.c b/lib/roken/memmem.c new file mode 100644 index 000000000000..3f9c6bcfd788 --- /dev/null +++ b/lib/roken/memmem.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> +#include <stdlib.h> +#include <string.h> + +#ifndef HAVE_MEMMEM +#include "roken.h" +ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL +memmem(const void *haystack, + size_t haystacklen, + const void *needle, + size_t needlelen) +{ + const unsigned char *hs = haystack; + const unsigned char *n = needle; + size_t hsi, ni; + + if (haystacklen < needlelen || haystacklen == 0) + return NULL; + /* + * Imagine a haystack of length 5 and needle of length 2, then the largest + * index in the haystack at which we can bother looking for the needle is: + * + * 0 1 2 3 4 + * +---------+ + * |?|?|?|?|?| + * +---------+ + * ^ + * \ + * here, at index 3, which is 5 - 2, and less than (5 - 2 + 1). + */ + for (hsi = 0, ni = 0; hsi < (haystacklen - needlelen + 1); hsi++, ni = 0) { + while (ni < needlelen && n[ni] == hs[hsi + ni]) + ni++; + if (ni == needlelen) + return rk_UNCONST(&hs[hsi]); + } + return NULL; +} +#endif diff --git a/lib/roken/mergesort.c b/lib/roken/mergesort.c new file mode 100644 index 000000000000..ba51889b5d67 --- /dev/null +++ b/lib/roken/mergesort.c @@ -0,0 +1,50 @@ +/*********************************************************************** + * Copyright (c) 2020, AuriStor, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + **********************************************************************/ + +#include <config.h> +#include "roken.h" + +static int +mergesort_compar_thunk(const void *a, const void *b, void *thunk) +{ + int (*compar)(const void *, const void *) = thunk; + + return compar(a, b); +} + +int ROKEN_LIB_FUNCTION +mergesort(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *)) +{ + return rk_mergesort_r(base, nel, width, + mergesort_compar_thunk, compar); +} + diff --git a/lib/roken/mergesort_r.c b/lib/roken/mergesort_r.c new file mode 100644 index 000000000000..4fbcd7033274 --- /dev/null +++ b/lib/roken/mergesort_r.c @@ -0,0 +1,338 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Peter McIlroy. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> +#include "roken.h" + +/* + * Hybrid exponential search/linear search merge sort with hybrid + * natural/pairwise first pass. Requires about .3% more comparisons + * for random data than LSMS with pairwise first pass alone. + * It works for objects as small as two bytes. + */ + +#define NATURAL +#define THRESHOLD 16 /* Best choice for natural merge cut-off. */ + +/* #define NATURAL to get hybrid natural merge. + * (The default is pairwise merging.) + */ + +#include <sys/types.h> + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +typedef int (*cmp_t)(const void *, const void *, void *); + +static void setup(u_char *, u_char *, size_t, size_t, cmp_t, void *); +static void insertionsort(u_char *, size_t, size_t, cmp_t, void *); + +#define ISIZE sizeof(int) +#define PSIZE sizeof(u_char *) +#define ICOPY_LIST(src, dst, last) \ + do \ + *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \ + while(src < last) +#define ICOPY_ELT(src, dst, i) \ + do \ + *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \ + while (i -= ISIZE) + +#define CCOPY_LIST(src, dst, last) \ + do \ + *dst++ = *src++; \ + while (src < last) +#define CCOPY_ELT(src, dst, i) \ + do \ + *dst++ = *src++; \ + while (i -= 1) + +/* + * Find the next possible pointer head. (Trickery for forcing an array + * to do double duty as a linked list when objects do not align with word + * boundaries. + */ +/* Assumption: PSIZE is a power of 2. */ +#define EVAL(p) (u_char **) \ + ((((uintptr_t)p + PSIZE - 1) & ~(PSIZE - 1))) + +/* + * Arguments are as for qsort_r, except thunk is moved to the last + * parameter for glibc compatibility. See: + * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214248 + */ +int +mergesort_r(void *base, size_t nmemb, size_t size, cmp_t cmp, void *thunk) +{ + size_t i; + int sense; + int big, iflag; + u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; + u_char *list2, *list1, *p2, *p, *last, **p1; + u_char *freeme = NULL; + + if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */ + errno = EINVAL; + return (-1); + } + + if (nmemb == 0) + return (0); + + /* + * XXX + * Stupid subtraction for the Cray. + */ + iflag = 0; + if (!(size % ISIZE) && !(((uintptr_t)base) % ISIZE)) + iflag = 1; + + if ((list2 = freeme = malloc(nmemb * size + PSIZE)) == NULL) + return (-1); + + list1 = base; + setup(list1, list2, nmemb, size, cmp, thunk); + last = list2 + nmemb * size; + i = big = 0; + while (*EVAL(list2) != last) { + l2 = list1; + p1 = EVAL(list1); + for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) { + p2 = *EVAL(p2); + f1 = l2; + f2 = l1 = list1 + (p2 - list2); + if (p2 != last) + p2 = *EVAL(p2); + l2 = list1 + (p2 - list2); + while (f1 < l1 && f2 < l2) { + if (cmp(f1, f2, thunk) <= 0) { + q = f2; + b = f1, t = l1; + sense = -1; + } else { + q = f1; + b = f2, t = l2; + sense = 0; + } + if (!big) { /* here i = 0 */ + while ((b += size) < t && cmp(q, b, thunk) >sense) + if (++i == 6) { + big = 1; + goto EXPONENTIAL; + } + } else { +EXPONENTIAL: for (i = size; ; i <<= 1) + if ((p = (b + i)) >= t) { + if ((p = t - size) > b && + cmp(q, p, thunk) <= sense) + t = p; + else + b = p; + break; + } else if (cmp(q, p, thunk) <= sense) { + t = p; + if (i == size) + big = 0; + goto FASTCASE; + } else + b = p; + while (t > b+size) { + i = (((t - b) / size) >> 1) * size; + if (cmp(q, p = b + i, thunk) <= sense) + t = p; + else + b = p; + } + goto COPY; +FASTCASE: while (i > size) + if (cmp(q, + p = b + (i >>= 1), thunk) <= sense) + t = p; + else + b = p; +COPY: b = t; + } + i = size; + if (q == f1) { + if (iflag) { + ICOPY_LIST(f2, tp2, b); + ICOPY_ELT(f1, tp2, i); + } else { + CCOPY_LIST(f2, tp2, b); + CCOPY_ELT(f1, tp2, i); + } + } else { + if (iflag) { + ICOPY_LIST(f1, tp2, b); + ICOPY_ELT(f2, tp2, i); + } else { + CCOPY_LIST(f1, tp2, b); + CCOPY_ELT(f2, tp2, i); + } + } + } + if (f2 < l2) { + if (iflag) + ICOPY_LIST(f2, tp2, l2); + else + CCOPY_LIST(f2, tp2, l2); + } else if (f1 < l1) { + if (iflag) + ICOPY_LIST(f1, tp2, l1); + else + CCOPY_LIST(f1, tp2, l1); + } + *p1 = l2; + } + tp2 = list1; /* swap list1, list2 */ + list1 = list2; + list2 = tp2; + last = list2 + nmemb*size; + } + if (base == list2) + memmove(list2, list1, nmemb*size); + free(freeme); + return (0); +} + +#define swap(a, b) { \ + s = b; \ + i = size; \ + do { \ + tmp = *a; *a++ = *s; *s++ = tmp; \ + } while (--i); \ + a -= size; \ + } +#define reverse(bot, top) { \ + s = top; \ + do { \ + i = size; \ + do { \ + tmp = *bot; *bot++ = *s; *s++ = tmp; \ + } while (--i); \ + s -= size2; \ + } while(bot < s); \ +} + +/* + * Optional hybrid natural/pairwise first pass. Eats up list1 in runs of + * increasing order, list2 in a corresponding linked list. Checks for runs + * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL + * is defined. Otherwise simple pairwise merging is used.) + */ +void +setup(u_char *list1, u_char *list2, size_t n, size_t size, cmp_t cmp, void *thunk) +{ + int i, length, size2, tmp, sense; + u_char *f1, *f2, *s, *l2, *last, *p2; + + size2 = size*2; + if (n <= 5) { + insertionsort(list1, n, size, cmp, thunk); + *EVAL(list2) = (u_char*) list2 + n*size; + return; + } + /* + * Avoid running pointers out of bounds; limit n to evens + * for simplicity. + */ + i = 4 + (n & 1); + insertionsort(list1 + (n - i) * size, i, size, cmp, thunk); + last = list1 + size * (n - i); + *EVAL(list2 + (last - list1)) = list2 + n * size; + +#ifdef NATURAL + p2 = list2; + f1 = list1; + sense = (cmp(f1, f1 + size, thunk) > 0); + for (; f1 < last; sense = !sense) { + length = 2; + /* Find pairs with same sense. */ + for (f2 = f1 + size2; f2 < last; f2 += size2) { + if ((cmp(f2, f2+ size, thunk) > 0) != sense) + break; + length += 2; + } + if (length < THRESHOLD) { /* Pairwise merge */ + do { + p2 = *EVAL(p2) = f1 + size2 - list1 + list2; + if (sense > 0) + swap (f1, f1 + size); + } while ((f1 += size2) < f2); + } else { /* Natural merge */ + l2 = f2; + for (f2 = f1 + size2; f2 < l2; f2 += size2) { + if ((cmp(f2-size, f2, thunk) > 0) != sense) { + p2 = *EVAL(p2) = f2 - list1 + list2; + if (sense > 0) + reverse(f1, f2-size); + f1 = f2; + } + } + if (sense > 0) + reverse (f1, f2-size); + f1 = f2; + if (f2 < last || cmp(f2 - size, f2, thunk) > 0) + p2 = *EVAL(p2) = f2 - list1 + list2; + else + p2 = *EVAL(p2) = list2 + n*size; + } + } +#else /* pairwise merge only. */ + for (f1 = list1, p2 = list2; f1 < last; f1 += size2) { + p2 = *EVAL(p2) = p2 + size2; + if (cmp (f1, f1 + size) > 0) + swap(f1, f1 + size); + } +#endif /* NATURAL */ +} + +/* + * This is to avoid out-of-bounds addresses in sorting the + * last 4 elements. + */ +static void +insertionsort(u_char *a, size_t n, size_t size, cmp_t cmp, void *thunk) +{ + u_char *ai, *s, *t, *u, tmp; + int i; + + for (ai = a+size; --n >= 1; ai += size) + for (t = ai; t > a; t -= size) { + u = t - size; + if (cmp(u, t, thunk) <= 0) + break; + swap(u, t); + } +} diff --git a/lib/roken/mkdir.c b/lib/roken/mkdir.c index 918ff65c610f..5ed4c0d33254 100644 --- a/lib/roken/mkdir.c +++ b/lib/roken/mkdir.c @@ -33,24 +33,21 @@ #include <config.h> -#ifdef HAVE_DIRECT_H +#ifdef WIN32 #include <direct.h> #endif #include "roken.h" -#ifdef MKDIR_DOES_NOT_HAVE_MODE - #undef mkdir -#else +#ifndef WIN32 #undef rk_mkdir #endif int ROKEN_LIB_FUNCTION rk_mkdir(const char *pathname, mode_t mode) { -#ifndef MKDIR_DOES_NOT_HAVE_MODE - return mkdir(pathname, mode); -#else - /* Windows does not provide the ability to set access permissions */ +#ifdef WIN32 return _mkdir(pathname); +#else + return mkdir(pathname, mode); #endif } diff --git a/lib/roken/get_default_username.c b/lib/roken/mkdtemp.c index da6806b15b40..c9f7463e9504 100644 --- a/lib/roken/get_default_username.c +++ b/lib/roken/mkdtemp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 1999 Kungliga Tekniska Högskolan + * Copyright (c) 2020 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,51 +33,54 @@ #include <config.h> -#include "roken.h" +#include <sys/stat.h> +#include <sys/types.h> +#include <string.h> +#include <errno.h> -/* - * Try to return what should be considered the default username or - * NULL if we can't guess at all. - */ +#include <roken.h> -ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL -get_default_username (void) -{ - const char *user; +#ifndef O_APPEND +#define O_APPEND 0 +#endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif +#ifndef O_SYNC +#define O_SYNC 0 +#endif - user = getenv ("USER"); - if (user == NULL) - user = getenv ("LOGNAME"); - if (user == NULL) - user = getenv ("USERNAME"); +#ifndef HAVE_MKDTEMP +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +mkdtemp(char *template) +{ + size_t len = strlen(template) - 1; + size_t start, i; + pid_t val = getpid(); -#if defined(HAVE_GETLOGIN) && !defined(POSIX_GETLOGIN) - if (user == NULL) { - user = (const char *)getlogin (); - if (user != NULL) - return user; + for (i = 0; i < len && i < 7 && template[len - i] == 'X'; i++) { + template[len - i] = '0' + val % 10; + val /= 10; + if (!val) + val = getpid(); } -#endif -#ifdef HAVE_PWD_H - { - uid_t uid = getuid (); - struct passwd *pwd; - if (user != NULL) { - pwd = k_getpwnam (user); - if (pwd != NULL && pwd->pw_uid == uid) - return user; - } - pwd = k_getpwuid (uid); - if (pwd != NULL) - return pwd->pw_name; + if (i < 6) { + errno = EINVAL; + return NULL; } -#endif -#ifdef _WIN32 - /* TODO: We can call GetUserNameEx() and figure out a - username. However, callers do not free the return value of this - function. */ -#endif - return user; + start = len - i; + do { + if (mkdir(template, 0700) == 0) + return template; + for (i = start + 1; i < len; i++) { + if (++(template[i]) == '9' + 1) + template[i] = 'a'; + if (template[i] <= 'z') + break; + template[i] = 'a'; + } + } while(1); } +#endif diff --git a/lib/roken/mkostemp.c b/lib/roken/mkostemp.c new file mode 100644 index 000000000000..8d739d80ee79 --- /dev/null +++ b/lib/roken/mkostemp.c @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include <string.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +#include <errno.h> + +#include <roken.h> + +#ifndef O_APPEND +#define O_APPEND 0 +#endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif +#ifndef O_SYNC +#define O_SYNC 0 +#endif + +#ifndef HAVE_MKOSTEMP +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +mkostemp(char *template, int flags) +{ + int fd = mkstemp(template); + + if (flags == 0) + return fd; + + if ((flags & O_CLOEXEC)) + rk_cloexec(fd); + + /* fcntl F_SETFL O_APPEND and O_SYNC. */ +#ifdef HAVE_FCNTL + if ((flags & (O_APPEND | O_SYNC))) { + int fl; + + if ((fl = fcntl(fd, F_GETFL)) == -1 || + fcntl(fd, F_SETFD, fl | (flags & (O_APPEND | O_SYNC))) == -1) { + int save_errno = errno; + + (void) unlink(template); + (void) close(fd); + errno = save_errno; + return -1; + } + } +#endif + return fd; +} +#endif diff --git a/lib/roken/net_write.c b/lib/roken/net_write.c index 1e8361999ea8..e66f56b75952 100644 --- a/lib/roken/net_write.c +++ b/lib/roken/net_write.c @@ -71,7 +71,7 @@ net_write (rk_socket_t fd, const void *buf, size_t nbytes) return nbytes; } -#else +#else /* defined(_WIN32) */ ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL net_write(rk_socket_t sock, const void *buf, size_t nbytes) @@ -102,6 +102,7 @@ net_write(rk_socket_t sock, const void *buf, size_t nbytes) count = send (sock, cbuf, rem, 0); #endif if (count < 0) { +#ifdef SOCKET_IS_NOT_AN_FD if (!use_write) { switch (rk_SOCK_ERRNO) { case WSAEINTR: @@ -111,7 +112,9 @@ net_write(rk_socket_t sock, const void *buf, size_t nbytes) default: return count; } - } else { + } else +#endif + { switch (errno) { case EINTR: continue; diff --git a/lib/roken/parse_bytes-test.c b/lib/roken/parse_bytes-test.c index 87f2fa8984aa..8f3831cbb08f 100644 --- a/lib/roken/parse_bytes-test.c +++ b/lib/roken/parse_bytes-test.c @@ -38,7 +38,7 @@ static struct testcase { int canonicalp; - int val; + int64_t val; const char *def_unit; const char *str; } tests[] = { @@ -52,6 +52,7 @@ static struct testcase { {1, 1024 * 1024, NULL, "1 megabyte"}, {0, 1025, NULL, "1 kilobyte 1"}, {1, 1025, NULL, "1 kilobyte 1 byte"}, + {1, 1024ULL * 1024 * 1024 * 1024, NULL, "1 terabyte"}, }; int @@ -62,20 +63,20 @@ main(int argc, char **argv) for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { char buf[256]; - int val = parse_bytes (tests[i].str, tests[i].def_unit); + int64_t val = parse_bytes (tests[i].str, tests[i].def_unit); if (val != tests[i].val) { - printf ("parse_bytes (%s, %s) = %d != %d\n", + printf ("parse_bytes (%s, %s) = %lld != %lld\n", tests[i].str, tests[i].def_unit ? tests[i].def_unit : "none", - val, tests[i].val); + (long long)val, (long long)tests[i].val); ++ret; } if (tests[i].canonicalp) { (void) unparse_bytes (tests[i].val, buf, sizeof(buf)); if (strcmp (tests[i].str, buf) != 0) { - printf ("unparse_bytes (%d) = \"%s\" != \"%s\"\n", - tests[i].val, buf, tests[i].str); + printf ("unparse_bytes (%lld) = \"%s\" != \"%s\"\n", + (long long)tests[i].val, buf, tests[i].str); ++ret; } } diff --git a/lib/roken/parse_bytes.c b/lib/roken/parse_bytes.c index 561079afc027..01ad553087be 100644 --- a/lib/roken/parse_bytes.c +++ b/lib/roken/parse_bytes.c @@ -37,6 +37,10 @@ #include "parse_bytes.h" static struct units bytes_units[] = { + { "petabyte", 1024ULL * 1024 * 1024 * 1024 * 1024 }, + { "PB", 1024ULL * 1024 * 1024 * 1024 * 1024 }, + { "terabyte", 1024ULL * 1024 * 1024 * 1024 }, + { "TB", 1024ULL * 1024 * 1024 * 1024 }, { "gigabyte", 1024 * 1024 * 1024 }, { "gbyte", 1024 * 1024 * 1024 }, { "GB", 1024 * 1024 * 1024 }, @@ -50,26 +54,28 @@ static struct units bytes_units[] = { }; static struct units bytes_short_units[] = { + { "PB", 1024ULL * 1024 * 1024 * 1024 * 1024 }, + { "TB", 1024ULL * 1024 * 1024 * 1024 }, { "GB", 1024 * 1024 * 1024 }, { "MB", 1024 * 1024 }, { "KB", 1024 }, { NULL, 0 } }; -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -parse_bytes (const char *s, const char *def_unit) +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL +parse_bytes(const char *s, const char *def_unit) { return parse_units (s, bytes_units, def_unit); } ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_bytes (int t, char *s, size_t len) +unparse_bytes(int64_t t, char *s, size_t len) { return unparse_units (t, bytes_units, s, len); } ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_bytes_short (int t, char *s, size_t len) +unparse_bytes_short (int64_t t, char *s, size_t len) { return unparse_units_approx (t, bytes_short_units, s, len); } diff --git a/lib/roken/parse_bytes.h b/lib/roken/parse_bytes.h index 8a88eca49b1d..5148fc603989 100644 --- a/lib/roken/parse_bytes.h +++ b/lib/roken/parse_bytes.h @@ -36,23 +36,15 @@ #ifndef __PARSE_BYTES_H__ #define __PARSE_BYTES_H__ -#ifndef ROKEN_LIB_FUNCTION -#ifdef _WIN32 -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL __cdecl -#else -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL -#endif -#endif +#include <roken.h> -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -parse_bytes (const char *s, const char *def_unit); +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL +parse_bytes(const char *s, const char *def_unit); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_bytes (int t, char *s, size_t len); +unparse_bytes(int64_t t, char *s, size_t len); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_bytes_short (int t, char *s, size_t len); +unparse_bytes_short(int64_t t, char *s, size_t len); #endif /* __PARSE_BYTES_H__ */ diff --git a/lib/roken/parse_time.c b/lib/roken/parse_time.c index febd6a5d2bf6..f5a99e31a84b 100644 --- a/lib/roken/parse_time.c +++ b/lib/roken/parse_time.c @@ -50,20 +50,20 @@ static struct units time_units[] = { {NULL, 0}, }; -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL parse_time (const char *s, const char *def_unit) { return parse_units (s, time_units, def_unit); } ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL -unparse_time (int t, char *s, size_t len) +unparse_time(int64_t t, char *s, size_t len) { return unparse_units (t, time_units, s, len); } ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL -unparse_time_approx (int t, char *s, size_t len) +unparse_time_approx(int64_t t, char *s, size_t len) { return unparse_units_approx (t, time_units, s, len); } @@ -73,3 +73,32 @@ print_time_table (FILE *f) { print_units_table (time_units, f); } + +#undef parse_time +#undef unparse_time +#undef unparse_time_approx +#undef print_time_table + +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL +parse_time(const char *s, const char *def_unit) +{ + return rk_parse_units(s, time_units, def_unit); +} + +ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL +unparse_time(int64_t t, char *s, size_t len) +{ + return rk_unparse_units(t, time_units, s, len); +} + +ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL +unparse_time_approx(int64_t t, char *s, size_t len) +{ + return rk_unparse_units_approx(t, time_units, s, len); +} + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +print_time_table(FILE *f) +{ + rk_print_units_table(time_units, f); +} diff --git a/lib/roken/parse_time.cat3 b/lib/roken/parse_time.cat3 deleted file mode 100644 index 5aab1da9ca05..000000000000 --- a/lib/roken/parse_time.cat3 +++ /dev/null @@ -1,111 +0,0 @@ -PARSE_TIME(3) BSD Library Functions Manual PARSE_TIME(3) - -[1mNAME[0m - [1mparse_time[22m, [1mprint_time_table[22m, [1munparse_time[22m, [1munparse_time_approx[22m, -- parse - and unparse time intervals - -[1mLIBRARY[0m - The roken library (libroken, -lroken) - -[1mSYNOPSIS[0m - [1m#include <parse_time.h>[0m - - [4mint[0m - [1mparse_time[22m([4mconst[24m [4mchar[24m [4m*timespec[24m, [4mconst[24m [4mchar[24m [4m*def_unit[24m); - - [4mvoid[0m - [1mprint_time_table[22m([4mFILE[24m [4m*f[24m); - - [4msize_t[0m - [1munparse_time[22m([4mint[24m [4mseconds[24m, [4mchar[24m [4m*buf[24m, [4msize_t[24m [4mlen[24m); - - [4msize_t[0m - [1munparse_time_approx[22m([4mint[24m [4mseconds[24m, [4mchar[24m [4m*buf[24m, [4msize_t[24m [4mlen[24m); - -[1mDESCRIPTION[0m - The [1mparse_time[22m() function converts the period of time specified into a - number of seconds. The [4mtimespec[24m can be any number of <number unit> pairs - separated by comma and whitespace. The number can be negative. Numbers - without explicit units are taken as being [4mdef_unit[24m. - - The [1munparse_time[22m() and [1munparse_time_approx[22m() do the opposite of - [1mparse_time[22m(), that is they take a number of seconds and express that as - human readable strings. [4munparse_time[24m produces an exact time, while - [4munparse_time_approx[24m restricts the result to include only one unit. - - [1mprint_time_table[22m() prints a descriptive list of available units on the - passed file descriptor. - - The possible units include: - second, s - minute, m - hour, h - day - week seven days - month 30 days - year 365 days - - Units names can be arbitrarily abbreviated (as long as they are unique). - -[1mRETURN VALUES[0m - [1mparse_time[22m() returns the number of seconds that represents the expression - in [4mtimespec[24m or -1 on error. [1munparse_time[22m() and [1munparse_time_approx[22m() re- - turn the number of characters written to [4mbuf[24m. if the return value is - greater than or equal to the [4mlen[24m argument, the string was too short and - some of the printed characters were discarded. - -[1mEXAMPLES[0m - #include <stdio.h> - #include <parse_time.h> - - int - main(int argc, char **argv) - { - int i; - int result; - char buf[128]; - print_time_table(stdout); - for (i = 1; i < argc; i++) { - result = parse_time(argv[i], "second"); - if(result == -1) { - fprintf(stderr, "%s: parse error\n", argv[i]); - continue; - } - printf("--\n"); - printf("parse_time = %d\n", result); - unparse_time(result, buf, sizeof(buf)); - printf("unparse_time = %s\n", buf); - unparse_time_approx(result, buf, sizeof(buf)); - printf("unparse_time_approx = %s\n", buf); - } - return 0; - } - - $ ./a.out "1 minute 30 seconds" "90 s" "1 y -1 s" - 1 year = 365 days - 1 month = 30 days - 1 week = 7 days - 1 day = 24 hours - 1 hour = 60 minutes - 1 minute = 60 seconds - 1 second - -- - parse_time = 90 - unparse_time = 1 minute 30 seconds - unparse_time_approx = 1 minute - -- - parse_time = 90 - unparse_time = 1 minute 30 seconds - unparse_time_approx = 1 minute - -- - parse_time = 31535999 - unparse_time = 12 months 4 days 23 hours 59 minutes 59 seconds - unparse_time_approx = 12 months - -[1mBUGS[0m - Since [1mparse_time[22m() returns -1 on error there is no way to parse "minus - one second". Currently "s" at the end of units is ignored. This is a - hack for English plural forms. If these functions are ever localised, - this scheme will have to change. - -HEIMDAL November 17, 2013 HEIMDAL diff --git a/lib/roken/parse_time.h b/lib/roken/parse_time.h index dabcefd81a7e..c0f08f956670 100644 --- a/lib/roken/parse_time.h +++ b/lib/roken/parse_time.h @@ -36,24 +36,35 @@ #ifndef __PARSE_TIME_H__ #define __PARSE_TIME_H__ -#ifndef ROKEN_LIB_FUNCTION -#ifdef _WIN32 -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL __cdecl -#else -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL -#endif -#endif - -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +#include <roken.h> + +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL +parse_time (const char *s, const char *def_unit); + +ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL +unparse_time(int64_t t, char *s, size_t len); + +ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL +unparse_time_approx(int64_t t, char *s, size_t len); + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +print_time_table (FILE *f); + +/* And again, but renamed */ + +#define parse_time rk_parse_time +#define unparse_time rk_unparse_time +#define unparse_time_approx rk_unparse_time_approx +#define print_time_table rk_print_time_table + +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL parse_time (const char *s, const char *def_unit); ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL -unparse_time (int t, char *s, size_t len); +unparse_time(int64_t t, char *s, size_t len); ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL -unparse_time_approx (int t, char *s, size_t len); +unparse_time_approx(int64_t t, char *s, size_t len); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL print_time_table (FILE *f); diff --git a/lib/roken/parse_units.c b/lib/roken/parse_units.c index 8b3cdf40e59e..017eedf376bd 100644 --- a/lib/roken/parse_units.c +++ b/lib/roken/parse_units.c @@ -44,15 +44,112 @@ * def_unit defines the default unit. */ -static int -parse_something (const char *s, const struct units *units, - const char *def_unit, - int (*func)(int res, int val, unsigned mult), - int init, - int accept_no_val_p) +static int64_t +parse_something_signed(const char *s, const struct units *units, + const char *def_unit, + int64_t (*func)(int64_t res, int64_t val, uint64_t mult), + int64_t init, + int accept_no_val_p) +{ + const char *p; + int64_t res = init; + unsigned def_mult = 1; + + if (def_unit != NULL) { + const struct units *u; + + for (u = units; u->name; ++u) { + if (strcasecmp (u->name, def_unit) == 0) { + def_mult = u->mult; + break; + } + } + if (u->name == NULL) + return -1; + } + + p = s; + while (*p) { + int64_t val; + char *next; + const struct units *u, *partial_unit; + size_t u_len; + unsigned partial; + int no_val_p = 0; + + while (isspace((unsigned char)*p) || *p == ',') + ++p; + + val = strtoll(p, &next, 0); + if (p == next) { + val = 0; + if(!accept_no_val_p) + return -1; + no_val_p = 1; + } + p = next; + while (isspace((unsigned char)*p)) + ++p; + if (*p == '\0') { + res = (*func)(res, val, def_mult); + if (res < 0) + return res; + break; + } else if (*p == '+') { + ++p; + val = 1; + } else if (*p == '-') { + ++p; + val = -1; + } + if (no_val_p && val == 0) + val = 1; + u_len = strcspn (p, ", \t"); + partial = 0; + partial_unit = NULL; + if (u_len > 1 && p[u_len - 1] == 's') + --u_len; + for (u = units; u->name; ++u) { + if (strncasecmp (p, u->name, u_len) == 0) { + if (u_len == strlen (u->name)) { + p += u_len; + res = (*func)(res, val, u->mult); + if (res < 0) + return res; + break; + } else { + ++partial; + partial_unit = u; + } + } + } + if (u->name == NULL) { + if (partial == 1) { + p += u_len; + res = (*func)(res, val, partial_unit->mult); + if (res < 0) + return res; + } else { + return -1; + } + } + if (*p == 's') + ++p; + while (isspace((unsigned char)*p)) + ++p; + } + return res; +} + +static uint64_t +parse_something_unsigned(const char *s, const struct units *units, + const char *def_unit, + uint64_t (*func)(uint64_t res, int64_t val, uint64_t mult), + uint64_t init, + int accept_no_val_p) { const char *p; - int res = init; + int64_t res = init; unsigned def_mult = 1; if (def_unit != NULL) { @@ -70,17 +167,17 @@ parse_something (const char *s, const struct units *units, p = s; while (*p) { - int val; + int64_t val; char *next; const struct units *u, *partial_unit; size_t u_len; unsigned partial; int no_val_p = 0; - while(isspace((unsigned char)*p) || *p == ',') + while (isspace((unsigned char)*p) || *p == ',') ++p; - val = strtol(p, &next, 0); + val = strtoll(p, &next, 0); if (p == next) { val = 0; if(!accept_no_val_p) @@ -135,6 +232,8 @@ parse_something (const char *s, const struct units *units, } if (*p == 's') ++p; + while (isspace((unsigned char)*p)) + ++p; } return res; } @@ -143,17 +242,17 @@ parse_something (const char *s, const struct units *units, * The string consists of a sequence of `n unit' */ -static int -acc_units(int res, int val, unsigned mult) +static int64_t +acc_units(int64_t res, int64_t val, uint64_t mult) { return res + val * mult; } -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL parse_units (const char *s, const struct units *units, const char *def_unit) { - return parse_something (s, units, def_unit, acc_units, 0, 0); + return parse_something_signed(s, units, def_unit, acc_units, 0, 0); } /* @@ -162,8 +261,8 @@ parse_units (const char *s, const struct units *units, * the function value. */ -static int -acc_flags(int res, int val, unsigned mult) +static uint64_t +acc_flags(uint64_t res, int64_t val, uint64_t mult) { if(val == 1) return res | mult; @@ -175,11 +274,10 @@ acc_flags(int res, int val, unsigned mult) return -1; } -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -parse_flags (const char *s, const struct units *units, - int orig) +ROKEN_LIB_FUNCTION uint64_t ROKEN_LIB_CALL +parse_flags(const char *s, const struct units *units, uint64_t orig) { - return parse_something (s, units, NULL, acc_flags, orig, 1); + return parse_something_unsigned (s, units, NULL, acc_flags, orig, 1); } /* @@ -188,27 +286,70 @@ parse_flags (const char *s, const struct units *units, */ static int -unparse_something (int num, const struct units *units, char *s, size_t len, - int (*print) (char *, size_t, int, const char *, int), - int (*update) (int, unsigned), - const char *zero_string) +unparse_something_signed(int64_t num, const struct units *units, char *s, + size_t len, + int64_t (*get_divisor)(int64_t, uint64_t), + int (*print)(char *, size_t, int64_t, const char *, int64_t), + int64_t (*update)(int64_t, uint64_t), + const char *zero_string) { const struct units *u; int ret = 0, tmp; if (num == 0) return snprintf (s, len, "%s", zero_string); + if (len) + s[0] = '\0'; + if (num < 0) + return -1; + + for (u = units; num > 0 && u->name; ++u) { + long long divisor = get_divisor(num, u->mult); + + if (divisor) { + num = (*update)(num, u->mult); + tmp = (*print)(s, len, divisor, u->name, num); + if (tmp < 0) + return tmp; + if ((size_t)tmp > len) { + len = 0; + s = NULL; + } else { + len -= tmp; + s += tmp; + } + ret += tmp; + } + } + return ret; +} + +static int +unparse_something_unsigned(uint64_t num, const struct units *units, char *s, + size_t len, + uint64_t (*get_divisor)(uint64_t, uint64_t), + int (*print)(char *, size_t, uint64_t, const char *, uint64_t), + uint64_t (*update)(uint64_t, uint64_t), + const char *zero_string) +{ + const struct units *u; + int64_t tmp; + int ret = 0; + + if (num == 0) + return snprintf (s, len, "%s", zero_string); + if (len) + s[0] = '\0'; for (u = units; num > 0 && u->name; ++u) { - int divisor; + long long divisor = get_divisor(num, u->mult); - divisor = num / u->mult; if (divisor) { num = (*update) (num, u->mult); tmp = (*print) (s, len, divisor, u->name, num); if (tmp < 0) return tmp; - if (tmp > (int) len) { + if ((size_t)tmp > len) { len = 0; s = NULL; } else { @@ -222,22 +363,26 @@ unparse_something (int num, const struct units *units, char *s, size_t len, } static int -print_unit (char *s, size_t len, int divisor, const char *name, int rem) +print_unit(char *s, size_t len, int64_t divisor, const char *name, int64_t rem) { - return snprintf (s, len, "%u %s%s%s", - divisor, name, - divisor == 1 ? "" : "s", - rem > 0 ? " " : ""); + return snprintf(s, len, "%lld %s%s%s", (long long)divisor, name, + divisor == 1 ? "" : "s", rem > 0 ? " " : ""); } -static int -update_unit (int in, unsigned mult) +static int64_t +get_divisor_unit(int64_t in, uint64_t mult) +{ + return in / mult; +} + +static int64_t +update_unit(int64_t in, uint64_t mult) { return in % mult; } -static int -update_unit_approx (int in, unsigned mult) +static int64_t +update_unit_approx(int64_t in, uint64_t mult) { if (in / mult > 0) return 0; @@ -246,21 +391,18 @@ update_unit_approx (int in, unsigned mult) } ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_units (int num, const struct units *units, char *s, size_t len) +unparse_units(int64_t num, const struct units *units, char *s, size_t len) { - return unparse_something (num, units, s, len, - print_unit, - update_unit, - "0"); + return unparse_something_signed(num, units, s, len, + get_divisor_unit, print_unit, update_unit, + "0"); } ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_units_approx (int num, const struct units *units, char *s, size_t len) +unparse_units_approx(int64_t num, const struct units *units, char *s, size_t len) { - return unparse_something (num, units, s, len, - print_unit, - update_unit_approx, - "0"); + return unparse_something_signed(num, units, s, len, get_divisor_unit, + print_unit, update_unit_approx, "0"); } ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL @@ -296,25 +438,29 @@ print_units_table (const struct units *units, FILE *f) } } +static uint64_t +get_divisor_flag(uint64_t in, uint64_t mult) +{ + return in & mult; +} + static int -print_flag (char *s, size_t len, int divisor, const char *name, int rem) +print_flag(char *s, size_t len, uint64_t divisor, const char *name, uint64_t rem) { return snprintf (s, len, "%s%s", name, rem > 0 ? ", " : ""); } -static int -update_flag (int in, unsigned mult) +static uint64_t +update_flag(uint64_t in, uint64_t mult) { - return in - mult; + return in & ~mult; } ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_flags (int num, const struct units *units, char *s, size_t len) +unparse_flags (uint64_t num, const struct units *units, char *s, size_t len) { - return unparse_something (num, units, s, len, - print_flag, - update_flag, - ""); + return unparse_something_unsigned(num, units, s, len, get_divisor_flag, + print_flag, update_flag, ""); } ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL @@ -325,3 +471,54 @@ print_flags_table (const struct units *units, FILE *f) for(u = units; u->name; ++u) fprintf(f, "%s%s", u->name, (u+1)->name ? ", " : "\n"); } + +#undef parse_units +#undef unparse_units +#undef unparse_units_approx +#undef print_units_table +#undef parse_flags +#undef unparse_flags +#undef print_flags_table + +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL +parse_units(const char *s, const struct units *units, + const char *def_unit) +{ + return rk_parse_units(s, units, def_unit); +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +unparse_units(int64_t num, const struct units *units, char *s, size_t len) +{ + return rk_unparse_units(num, units, s, len); +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +unparse_units_approx(int64_t num, const struct units *units, char *s, size_t len) +{ + return rk_unparse_units_approx(num, units, s, len); +} + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +print_units_table(const struct units *units, FILE *f) +{ + rk_print_units_table(units, f); +} + +ROKEN_LIB_FUNCTION uint64_t ROKEN_LIB_CALL +parse_flags(const char *s, const struct units *units, int orig) +{ + return rk_parse_flags(s, units, orig); +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +unparse_flags(uint64_t num, const struct units *units, char *s, size_t len) +{ + return rk_unparse_flags(num, units, s, len); +} + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +print_flags_table (const struct units *units, FILE *f) +{ + rk_print_flags_table(units, f); +} diff --git a/lib/roken/parse_units.h b/lib/roken/parse_units.h index 2d1c28690682..d17897dda60f 100644 --- a/lib/roken/parse_units.h +++ b/lib/roken/parse_units.h @@ -38,6 +38,7 @@ #include <stdio.h> #include <stddef.h> +#include <stdint.h> #ifndef ROKEN_LIB_FUNCTION #ifdef _WIN32 @@ -51,29 +52,63 @@ struct units { const char *name; - unsigned mult; + uint64_t mult; }; -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL parse_units (const char *s, const struct units *units, const char *def_unit); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL print_units_table (const struct units *units, FILE *f); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +ROKEN_LIB_FUNCTION uint64_t ROKEN_LIB_CALL parse_flags (const char *s, const struct units *units, int orig); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_units (int num, const struct units *units, char *s, size_t len); +unparse_units(int64_t num, const struct units *units, char *s, size_t len); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +unparse_units_approx(int64_t num, const struct units *units, char *s, + size_t len); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +unparse_flags(uint64_t num, const struct units *units, char *s, size_t len); + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +print_flags_table (const struct units *units, FILE *f); + +/* And again, but renamed */ + +#define parse_units rk_parse_units +#define unparse_units rk_unparse_units +#define unparse_units_approx rk_unparse_units_approx +#define print_units_table rk_print_units_table +#define parse_flags rk_parse_flags +#define unparse_flags rk_unparse_flags +#define print_flags_table rk_print_flags_table + +ROKEN_LIB_FUNCTION int64_t ROKEN_LIB_CALL +parse_units (const char *s, const struct units *units, + const char *def_unit); + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +print_units_table (const struct units *units, FILE *f); + +ROKEN_LIB_FUNCTION uint64_t ROKEN_LIB_CALL +parse_flags(const char *s, const struct units *units, + uint64_t orig); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +unparse_units(int64_t num, const struct units *units, char *s, size_t len); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_units_approx (int num, const struct units *units, char *s, - size_t len); +unparse_units_approx(int64_t num, const struct units *units, char *s, + size_t len); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -unparse_flags (int num, const struct units *units, char *s, size_t len); +unparse_flags(uint64_t num, const struct units *units, char *s, size_t len); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL print_flags_table (const struct units *units, FILE *f); diff --git a/lib/roken/qsort.c b/lib/roken/qsort.c index 768981334f25..5849d86a912d 100644 --- a/lib/roken/qsort.c +++ b/lib/roken/qsort.c @@ -69,9 +69,7 @@ static inline void swapfunc(char *, char *, int, int); es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; static inline void -swapfunc(a, b, n, swaptype) - char *a, *b; - int n, swaptype; +swapfunc(char *a, char *b, int n, int swaptype) { if(swaptype <= 1) swapcode(long, a, b, n) diff --git a/lib/roken/rand.c b/lib/roken/rand.c index f2617d8ab2bc..59ff47add885 100644 --- a/lib/roken/rand.c +++ b/lib/roken/rand.c @@ -36,6 +36,7 @@ #ifdef HAVE_WIN32_RAND_S static int hasRand_s = 1; +#include "versionsupport.h" #endif void ROKEN_LIB_FUNCTION @@ -49,13 +50,7 @@ rk_random_init(void) srandom(time(NULL)); #else # ifdef HAVE_WIN32_RAND_S - OSVERSIONINFO osInfo; - - osInfo.dwOSVersionInfoSize = sizeof(osInfo); - hasRand_s = - (GetVersionEx(&osInfo) - && ((osInfo.dwMajorVersion > 5) || - (osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion >= 1))); + hasRand_s = IsWindowsXPOrGreater(); # endif srand (time(NULL)); #endif diff --git a/lib/roken/resolve-test.c b/lib/roken/resolve-test.c index 25cc98aafe3a..581600a5937d 100644 --- a/lib/roken/resolve-test.c +++ b/lib/roken/resolve-test.c @@ -159,7 +159,7 @@ test_rk_dns_srv_order(size_t run) if (rr->u.srv->priority < prio0 || (rr->u.srv->priority != prio0 && (i % 4 != 0 || rr->u.srv->priority > prio0 + 1))) { - printf("SRV RR order run %lu failed\n", run); + printf("SRV RR order run %zu failed\n", run); fail = 1; } prio0 = rr->u.srv->priority; diff --git a/lib/roken/resolve.c b/lib/roken/resolve.c index 98be0cb87f8a..31da4136d91a 100644 --- a/lib/roken/resolve.c +++ b/lib/roken/resolve.c @@ -629,14 +629,17 @@ rk_dns_srv_order(struct rk_dns_reply *r) struct rk_resource_record **srvs, **ss, **headp; struct rk_resource_record *rr; int num_srv = 0; + unsigned int srv_found = FALSE; rk_random_init(); for(rr = r->head; rr; rr = rr->next) - if(rr->type == rk_ns_t_srv) + if(rr->type == rk_ns_t_srv) { num_srv++; + srv_found = TRUE; + } - if(num_srv == 0) + if(srv_found == FALSE) return; srvs = malloc(num_srv * sizeof(*srvs)); diff --git a/lib/roken/rkpty.c b/lib/roken/rkpty.c index 619b7b6391a5..f7bfacabe7a5 100644 --- a/lib/roken/rkpty.c +++ b/lib/roken/rkpty.c @@ -123,7 +123,18 @@ open_pty(void) #ifdef HAVE_UNLOCKPT unlockpt(master); #endif - strlcpy(line, ptsname(master), sizeof(line)); +#ifdef HAVE_PTSNAME_R + if (ptsname_r(master, line, sizeof(line)) == -1) + err("Failed to open the pty master %s", *q); +#else + { + char *s = ptsname(master); + + if (s == NULL) + err("Failed to open the pty master %s", *q); + strlcpy(line, s, sizeof(line)); + } +#endif slave = open(line, O_RDWR); if (slave < 0) errx(1, "failed to open slave when using %s", *q); diff --git a/lib/roken/roken-common.h b/lib/roken/roken-common.h index 4766538a0d38..906b000336ce 100644 --- a/lib/roken/roken-common.h +++ b/lib/roken/roken-common.h @@ -166,6 +166,10 @@ #endif #endif +#ifndef MAX_PATH +#define MAX_PATH PATH_MAX +#endif + #ifndef RETSIGTYPE #define RETSIGTYPE void #endif @@ -288,6 +292,33 @@ #define __attribute__(x) #endif +/* + * for dlopen(3) + */ +#ifndef RTLD_LAZY +#define RTLD_LAZY 0 +#endif + +#ifndef RTLD_NOW +#define RTLD_NOW 0 +#endif + +#ifndef RTLD_GLOBAL +#define RTLD_GLOBAL 0 +#endif + +#ifndef RTLD_LOCAL +#define RTLD_LOCAL 0 +#endif + +#ifndef RTLD_GROUP +#define RTLD_GROUP 0 +#endif + +#ifndef RTLD_NODELETE +#define RTLD_NODELETE 0 +#endif + ROKEN_CPP_START #ifndef IRIX4 /* fix for compiler bug */ @@ -425,6 +456,10 @@ socket_set_reuseaddr (rk_socket_t, int); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_ipv6only (rk_socket_t, int); +#define socket_set_keepalive rk_socket_set_keepalive +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +socket_set_keepalive (rk_socket_t, int); + #define socket_to_fd rk_socket_to_fd ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL socket_to_fd(rk_socket_t, int); @@ -437,6 +472,12 @@ vstrcollect(va_list *ap); ROKEN_LIB_FUNCTION char ** ROKEN_LIB_CALL strcollect(char *first, ...); +ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL +rk_time_add(time_t, time_t); + +ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL +rk_time_sub(time_t, time_t); + #define timevalfix rk_timevalfix ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL timevalfix(struct timeval *t1); @@ -468,7 +509,7 @@ free_environment(char **); #define warnerr rk_warnerr ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_warnerr(int doerrno, const char *fmt, va_list ap) - __attribute__ ((__format__ (__printf__, 2, 0))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 0)); ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL rk_realloc(void *, size_t); @@ -480,7 +521,7 @@ rk_strpoolcollect(struct rk_strpool *); ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL rk_strpoolprintf(struct rk_strpool *, const char *, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 3)); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_strpoolfree(struct rk_strpool *); @@ -491,6 +532,9 @@ rk_dumpdata (const char *, const void *, size_t); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_undumpdata (const char *, void **, size_t *); +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_undumptext (const char *, char **, size_t *); + ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_xfree (void *); @@ -517,6 +561,9 @@ rk_random_init(void); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_mkdir(const char *, mode_t); +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_clzll(uint64_t); + ROKEN_CPP_END #endif /* __ROKEN_COMMON_H__ */ diff --git a/lib/roken/roken.awk b/lib/roken/roken.awk index 47313c843af2..00e60f026df9 100644 --- a/lib/roken/roken.awk +++ b/lib/roken/roken.awk @@ -12,6 +12,14 @@ BEGIN { print "#ifdef HAVE_ERRNO_H" print "#include <errno.h>" print "#endif" + print "#if !defined(__has_extension)" + print "#define __has_extension(x) 0" + print "#endif" + print "#ifndef ROKEN_REQUIRE_GNUC" + print "#define ROKEN_REQUIRE_GNUC(m,n,p) \\" + print " (((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= \\" + print " (((m) * 10000) + ((n) * 100) + (p)))" + print "#endif" print "" print "int main(int argc, char **argv)" print "{" diff --git a/lib/roken/roken.h.in b/lib/roken/roken.h.in index bf0f8c796a97..c72d259a37a0 100644 --- a/lib/roken/roken.h.in +++ b/lib/roken/roken.h.in @@ -1,6 +1,6 @@ /* -*- C -*- */ /* - * Copyright (c) 1995-2005 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2017 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -32,11 +32,11 @@ * SUCH DAMAGE. */ -#if defined(_WIN32) && _MSC_VER >= 1400 +# if defined(_WIN32) && _MSC_VER >= 1400 /* _CRT_RAND_S must be defined before including stdlib.h */ -# define _CRT_RAND_S -# define HAVE_WIN32_RAND_S 1 -#endif +# define _CRT_RAND_S +# define HAVE_WIN32_RAND_S 1 +# endif #include <stdio.h> #include <stdlib.h> @@ -48,20 +48,103 @@ #include <limits.h> #include <signal.h> -#ifndef ROKEN_LIB_FUNCTION -#ifdef _WIN32 -# define ROKEN_LIB_CALL __cdecl -# ifdef ROKEN_LIB_DYNAMIC +#ifdef HAVE_UTIL_H +#include <util.h> +#endif + +# ifndef ROKEN_LIB_FUNCTION +# ifdef _WIN32 +# ifdef ROKEN_LIB_DYNAMIC # define ROKEN_LIB_FUNCTION __declspec(dllimport) -# define ROKEN_LIB_VARIABLE __declspec(dllimport) -# else +# else # define ROKEN_LIB_FUNCTION +# endif +# else +# define ROKEN_LIB_FUNCTION +# endif +# endif + +# ifndef ROKEN_LIB_NORETURN_FUNCTION +# ifdef _WIN32 +# ifdef ROKEN_LIB_DYNAMIC +# define ROKEN_LIB_NORETURN_FUNCTION __declspec(dllimport noreturn) +# else +# define ROKEN_LIB_NORETURN_FUNCTION __declspec(noreturn) +# endif +# else +# define ROKEN_LIB_NORETURN_FUNCTION +# endif +# endif + +# ifndef ROKEN_LIB_CALL +# ifdef _WIN32 +# define ROKEN_LIB_CALL __cdecl +# else +# define ROKEN_LIB_CALL +# endif +# endif + +# ifndef ROKEN_LIB_VARIABLE +# ifdef _WIN32 +# ifdef ROKEN_LIB_DYNAMIC +# define ROKEN_LIB_VARIABLE __declspec(dllimport) +# else # define ROKEN_LIB_VARIABLE +# endif +# else +# define ROKEN_LIB_VARIABLE # endif +# endif + +#if !defined(__has_extension) +#define __has_extension(x) 0 +#endif + +#ifndef ROKEN_REQUIRE_GNUC +#define ROKEN_REQUIRE_GNUC(m,n,p) \ + (((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= \ + (((m) * 10000) + ((n) * 100) + (p))) +#endif + +#ifndef ROKEN_DEPRECATED +#if __has_extension(deprecated) || ROKEN_REQUIRE_GNUC(3,1,0) +#define ROKEN_DEPRECATED __attribute__ ((__deprecated__)) +#elif defined(_MSC_VER) && (_MSC_VER>1200) +#define ROKEN_DEPRECATED __declspec(deprecated) +#else +#define ROKEN_DEPRECATED +#endif +#endif + +#ifndef ROKEN_PRINTF_ATTRIBUTE +#if __has_extension(format) || ROKEN_REQUIRE_GNUC(3,1,0) +#define ROKEN_PRINTF_ATTRIBUTE(x) __attribute__ ((__format__ x)) +#else +#define ROKEN_PRINTF_ATTRIBUTE(x) +#endif +#endif + +#ifndef ROKEN_NORETURN_ATTRIBUTE +#if __has_extension(noreturn) || ROKEN_REQUIRE_GNUC(3,1,0) +#define ROKEN_NORETURN_ATTRIBUTE __attribute__ ((__noreturn__)) +#else +#define ROKEN_NORETURN_ATTRIBUTE +#endif +#endif + +#ifndef ROKEN_UNUSED_ATTRIBUTE +#if __has_extension(unused) || ROKEN_REQUIRE_GNUC(3,1,0) +#define ROKEN_UNUSED_ATTRIBUTE __attribute__ ((__unused__)) +#else +#define ROKEN_UNUSED_ATTRIBUTE +#endif +#endif + +#ifndef ROKEN_WARN_UNUSED_RESULT_ATTRIBUTE +#if __has_extension(warn_unused_result) || ROKEN_REQUIRE_GNUC(3,3,0) +#define ROKEN_WARN_UNUSED_RESULT_ATTRIBUTE __attribute__ ((__warn_unused_result__)) #else -#define ROKEN_LIB_FUNCTION -#define ROKEN_LIB_CALL -#define ROKEN_LIB_VARIABLE +#define ROKEN_WARN_UNUSED_RESULT_ATTRIBUTE #endif #endif @@ -101,7 +184,10 @@ typedef int rk_socket_t; #define rk_SOCK_ERRNO errno #define rk_INVALID_SOCKET (-1) -#define rk_SOCK_INIT() 0 +static inline ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_INIT(void) { + return 0; +} + #define rk_SOCK_EXIT() do { } while(0) #endif /* WinSock */ @@ -265,11 +351,15 @@ struct sockaddr_dl; #include <paths.h> #endif +#ifdef HAVE_DLFCN_H +#include <dlfcn.h> +#endif + #ifdef HAVE_DIRENT_H #include <dirent.h> #endif -#ifdef HAVE_DIRECT_H +#ifdef WIN32 #include <direct.h> #endif @@ -318,10 +408,6 @@ ROKEN_CPP_START #define fsync _commit -#define timezone _timezone - -#define tzname _tzname - #define _PIPE_BUFFER_SZ 8192 #define pipe(fds) _pipe((fds), _PIPE_BUFFER_SZ, O_BINARY); @@ -416,6 +502,11 @@ rk_wcsdup(const unsigned short *); #endif /* _MSC_VER */ +#ifndef HAVE_MEMMEM +#define memmem rk_smemmem +ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL memmem(const void *, size_t, const void *, size_t); +#endif + #ifdef HAVE_WINSOCK /* While we are at it, define WinSock specific scatter gather socket @@ -476,7 +567,7 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void); #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_snprintf (char *, size_t, const char *, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 4)); #endif #if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO) @@ -485,7 +576,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_vsnprintf (char *, size_t, const char *, va_list) - __attribute__ ((__format__ (__printf__, 3, 0))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 0)); #endif #if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO) @@ -494,7 +585,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_asprintf (char **, const char *, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 3)); #endif #if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO) @@ -503,7 +594,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_vasprintf (char **, const char *, va_list) - __attribute__ ((__format__ (__printf__, 2, 0))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 0)); #endif #if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO) @@ -512,7 +603,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_asnprintf (char **, size_t, const char *, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 4)); #endif #if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO) @@ -521,7 +612,19 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL #endif ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL vasnprintf (char **, size_t, const char *, va_list) - __attribute__ ((__format__ (__printf__, 3, 0))); + ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 0)); +#endif + +#if !defined(HAVE_EVASPRINTF) || defined(NEED_EVASPRINTF_PROTO) +#define evasprintf rk_evasprintf +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_evasprintf(const char *format, va_list args); +#endif + +#if !defined(HAVE_EASPRINTF) || defined(NEED_EASPRINTF_PROTO) +#define easprintf rk_easprintf +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_easprintf(const char *format, ...); #endif #ifndef HAVE_STRDUP @@ -644,19 +747,8 @@ ROKEN_LIB_FUNCTION char* ROKEN_LIB_CALL getcwd(char *, size_t); #ifdef HAVE_PWD_H #include <pwd.h> -ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwnam (const char *); -ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL k_getpwuid (uid_t); #endif -#ifdef POSIX_GETPWNAM_R -#define rk_getpwnam_r(_n, _pw, _b, _sz, _pwd) getpwnam_r(_n, _pw, _b, _sz, _pwd) -#else -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -rk_getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); -#endif - -ROKEN_LIB_FUNCTION const char * ROKEN_LIB_CALL get_default_username (void); - #ifndef HAVE_SETEUID #define seteuid rk_seteuid ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL seteuid(uid_t); @@ -679,11 +771,14 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL lstat(const char *, struct stat *); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkstemp(char *); #endif -#ifndef HAVE_CGETENT -#define cgetent rk_cgetent -#define cgetstr rk_cgetstr -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetent(char **, char **, const char *); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL cgetstr(char *, const char *, char **); +#ifndef HAVE_MKOSTEMP +#define mkostemp rk_mkostemp +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL mkostemp(char *, int); +#endif + +#ifndef HAVE_MKDTEMP +#define mkdtemp rk_mkdtemp +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL mkdtemp(char *); #endif #ifndef HAVE_INITGROUPS @@ -702,7 +797,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_rename(const char *, const char *); #define rk_rename(__rk_rn_from,__rk_rn_to) rename(__rk_rn_from,__rk_rn_to) #endif -#ifdef MKDIR_DOES_NOT_HAVE_MODE +#ifdef WIN32 #define mkdir rk_mkdir #else #define rk_mkdir(__rk_rn_name, __rk_rn_mode) mkdir(__rk_rn_name,__rk_rn_mode) @@ -736,12 +831,6 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL innetgr(const char*, const char*, const char*, const char*); #endif -#ifndef HAVE_IRUSEROK -#define iruserok rk_iruserok -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL iruserok(unsigned, int, - const char *, const char *); -#endif - #if !defined(HAVE_GETHOSTNAME) || defined(NEED_GETHOSTNAME_PROTO) #ifndef HAVE_GETHOSTNAME #define gethostname rk_gethostname @@ -803,17 +892,17 @@ int rk_flock(int fd, int operation); #ifndef HAVE_DIRFD #ifdef HAVE_DIR_DD_FD #define dirfd(x) ((x)->dd_fd) +#elif defined(HAVE_DIR_D_FD) +#define dirfd(x) ((x)->d_fd) #else #ifndef _WIN32 /* Windows code never calls dirfd */ -#error Missing dirfd() and ->dd_fd +#error Missing dirfd() and ->dd_fd and ->d_fd #endif #endif #endif ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL tm2time (struct tm, int); -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL unix_verify_user(char *, char *); - ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_concat (char *, size_t, ...); ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_mconcat (char **, size_t, ...); @@ -823,7 +912,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_vconcat (char *, size_t, va_list); ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL roken_vmconcat (char **, size_t, va_list); -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL roken_detach_prep(int, char **, char *); +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_detach_prep(int, char **, char *); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL roken_detach_finish(const char *, int); ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL @@ -832,9 +921,20 @@ ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL net_read (rk_socket_t, void *, size_t); +ROKEN_LIB_FUNCTION unsigned long ROKEN_LIB_CALL + rk_getauxval(unsigned long); + ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL + rk_secure_getenv(const char *); + +#ifndef HAVE_SECURE_GETENV +#undef secure_getenv +#define secure_getenv(e) rk_secure_getenv(e) +#endif + #ifndef HAVE_STRUCT_WINSIZE struct winsize { unsigned short ws_row, ws_col; @@ -870,27 +970,27 @@ ROKEN_LIB_VARIABLE extern int opterr; #ifndef HAVE_GETIPNODEBYNAME #define getipnodebyname rk_getipnodebyname -ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL -getipnodebyname (const char *, int, int, int *); #endif +ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL +rk_getipnodebyname(const char *, int, int, int *); #ifndef HAVE_GETIPNODEBYADDR #define getipnodebyaddr rk_getipnodebyaddr -ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL -getipnodebyaddr (const void *, size_t, int, int *); #endif +ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL +rk_getipnodebyaddr(const void *, size_t, int, int *); #ifndef HAVE_FREEHOSTENT #define freehostent rk_freehostent -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL -freehostent (struct hostent *); #endif +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +rk_freehostent(struct hostent *); #ifndef HAVE_COPYHOSTENT #define copyhostent rk_copyhostent -ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL -copyhostent (const struct hostent *); #endif +ROKEN_LIB_FUNCTION struct hostent * ROKEN_LIB_CALL +rk_copyhostent(const struct hostent *); #ifndef HAVE_SOCKLEN_T typedef int socklen_t; @@ -956,27 +1056,27 @@ struct addrinfo { #ifndef HAVE_GETADDRINFO #define getaddrinfo rk_getaddrinfo -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -getaddrinfo(const char *, - const char *, - const struct addrinfo *, - struct addrinfo **); #endif +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_getaddrinfo(const char *, + const char *, + const struct addrinfo *, + struct addrinfo **); #ifndef HAVE_GETNAMEINFO #define getnameinfo rk_getnameinfo -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -getnameinfo(const struct sockaddr *, socklen_t, - char *, size_t, - char *, size_t, - int); #endif +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_getnameinfo(const struct sockaddr *, socklen_t, + char *, size_t, + char *, size_t, + int); #ifndef HAVE_FREEADDRINFO #define freeaddrinfo rk_freeaddrinfo -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL -freeaddrinfo(struct addrinfo *); #endif +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +rk_freeaddrinfo(struct addrinfo *); #ifndef HAVE_GAI_STRERROR #define gai_strerror rk_gai_strerror @@ -1005,6 +1105,17 @@ roken_getaddrinfo_hostspec(const char *, int, struct addrinfo **); ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL roken_getaddrinfo_hostspec2(const char *, int, int, struct addrinfo **); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_homedir(char *, size_t); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_appdatadir(char *, size_t); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_username(char *, size_t); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_loginname(char *, size_t); +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +roken_get_shell(char *, size_t); + #ifndef HAVE_STRFTIME #define strftime rk_strftime ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL @@ -1177,9 +1288,9 @@ vis(char *, int, int, int); #if !defined(HAVE_CLOSEFROM) #define closefrom rk_closefrom -ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL -closefrom(int); #endif +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_closefrom(int); #if !defined(HAVE_TIMEGM) #define timegm rk_timegm @@ -1193,6 +1304,20 @@ void rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *)); #endif +#if !defined(HAVE_MERGESORT) +#define mergesort rk_mergesort +int +mergesort(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *)); +#endif + +#if !defined(HAVE_MERGESORT_R) +#define mergesort_r rk_mergesort_r +int +mergesort_r(void *base, size_t nel, size_t width, + int (*compar)(const void *, const void *, void *), void *thunk); +#endif + #ifndef HAVE_MEMSET_S #define memset_s rk_memset_s ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL memset_s(void *s, size_t smax, @@ -1257,6 +1382,10 @@ int ROKEN_LIB_FUNCTION rk_socket(int, int, int); #define EWOULDBLOCK 140 #endif +#ifdef WIN32 +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +win32_getLibraryVersion(const char *libname, char **outname, char **outversion); +#endif #ifdef SOCKET_WRAPPER_REPLACE #include <socket_wrapper.h> diff --git a/lib/roken/roken_gethostby.c b/lib/roken/roken_gethostby.c index a2dda7e05a51..a2febd0d1690 100644 --- a/lib/roken/roken_gethostby.c +++ b/lib/roken/roken_gethostby.c @@ -84,11 +84,13 @@ setup_int(const char *proxy_host, short proxy_port, return 0; } -static void +static int split_spec(const char *spec, char **host, int *port, char **path, int def_port) { char *p; *host = strdup(spec); + if (*host == NULL) + return -1; p = strchr(*host, ':'); if(p) { *p++ = '\0'; @@ -98,12 +100,19 @@ split_spec(const char *spec, char **host, int *port, char **path, int def_port) *port = def_port; p = strchr(p ? p : *host, '/'); if(p) { - if(path) + if(path) { *path = strdup(p); + if (*path == NULL) { + free(*host); + *host = NULL; + return -1; + } + } *p = '\0'; }else if(path) *path = NULL; + return 0; } @@ -112,17 +121,22 @@ roken_gethostby_setup(const char *proxy_spec, const char *dns_spec) { char *proxy_host = NULL; int proxy_port = 0; - char *dns_host, *dns_path; + char *dns_host = NULL, *dns_path = NULL; int dns_port; + int ret; - int ret = -1; - - split_spec(dns_spec, &dns_host, &dns_port, &dns_path, 80); - if(dns_path == NULL) + ret = split_spec(dns_spec, &dns_host, &dns_port, &dns_path, 80); + if(ret) goto out; - if(proxy_spec) - split_spec(proxy_spec, &proxy_host, &proxy_port, NULL, 80); + if(proxy_spec) { + ret = split_spec(proxy_spec, &proxy_host, &proxy_port, NULL, 80); + if (ret) + goto out; + } ret = setup_int(proxy_host, proxy_port, dns_host, dns_port, dns_path); + if (ret) + goto out; + out: free(proxy_host); free(dns_host); diff --git a/lib/roken/rtbl.c b/lib/roken/rtbl.c index efcf55e58898..1e9e72b6e329 100644 --- a/lib/roken/rtbl.c +++ b/lib/roken/rtbl.c @@ -473,7 +473,7 @@ rtbl_format_json(rtbl_t table) if (c->num_rows > j) { char *header = c->header; - while (isspace((int)header[0])) /* trim off prefixed whitespace */ + while (isspace((unsigned char)header[0])) /* trim off prefixed whitespace */ header++; p = rk_strpoolprintf(p, "%s\"%s\" : \"%s\"", comma ? "," : "", header, diff --git a/lib/roken/rtbl.cat3 b/lib/roken/rtbl.cat3 deleted file mode 100644 index afa159e46cf5..000000000000 --- a/lib/roken/rtbl.cat3 +++ /dev/null @@ -1,150 +0,0 @@ -RTBL(3) BSD Library Functions Manual RTBL(3) - -[1mNAME[0m - [1mrtbl_create[22m, [1mrtbl_destroy[22m, [1mrtbl_set_flags[22m, [1mrtbl_get_flags[22m, - [1mrtbl_set_prefix[22m, [1mrtbl_set_separator[22m, [1mrtbl_set_column_prefix[22m, - [1mrtbl_set_column_affix_by_id[22m, [1mrtbl_add_column[22m, [1mrtbl_add_column_by_id[22m, - [1mrtbl_add_column_entry[22m, [1mrtbl_add_column_entry_by_id[22m, [1mrtbl_new_row[22m, - [1mrtbl_format [22m-- format data in simple tables - -[1mLIBRARY[0m - The roken library (libroken, -lroken) - -[1mSYNOPSIS[0m - [1m#include <rtbl.h>[0m - - [4mint[0m - [1mrtbl_add_column[22m([4mrtbl_t[24m [4mtable[24m, [4mconst[24m [4mchar[24m [4m*column_name[24m, - [4munsigned[24m [4mint[24m [4mflags[24m); - - [4mint[0m - [1mrtbl_add_column_by_id[22m([4mrtbl_t[24m [4mtable[24m, [4munsigned[24m [4mint[24m [4mcolumn_id[24m, - [4mconst[24m [4mchar[24m [4m*column_header[24m, [4munsigned[24m [4mint[24m [4mflags[24m); - - [4mint[0m - [1mrtbl_add_column_entry[22m([4mrtbl_t[24m [4mtable[24m, [4mconst[24m [4mchar[24m [4m*column_name[24m, - [4mconst[24m [4mchar[24m [4m*cell_entry[24m); - - [4mint[0m - [1mrtbl_add_column_entry_by_id[22m([4mrtbl_t[24m [4mtable[24m, [4munsigned[24m [4mint[24m [4mcolumn_id[24m, - [4mconst[24m [4mchar[24m [4m*cell_entry[24m); - - [4mrtbl_t[0m - [1mrtbl_create[22m([4mvoid[24m); - - [4mvoid[0m - [1mrtbl_destroy[22m([4mrtbl_t[24m [4mtable[24m); - - [4mint[0m - [1mrtbl_new_row[22m([4mrtbl_t[24m [4mtable[24m); - - [4mint[0m - [1mrtbl_set_column_affix_by_id[22m([4mrtbl_t[24m [4mtable[24m, [4munsigned[24m [4mint[24m [4mcolumn_id[24m, [4mconst[24m, - [4mchar[24m, [4m*prefix"[24m, [4mconst[24m [4mchar[24m [4m*suffix[24m); - - [4mint[0m - [1mrtbl_set_column_prefix[22m([4mrtbl_t[24m [4mtable[24m, [4mconst[24m [4mchar[24m [4m*column_name[24m, - [4mconst[24m [4mchar[24m [4m*prefix[24m); - - [4munsigned[24m [4mint[0m - [1mrtbl_get_flags[22m([4mrtbl_t[24m [4mtable[24m); - - [4mvoid[0m - [1mrtbl_set_flags[22m([4mrtbl_t[24m [4mtable[24m, [4munsigned[24m [4mint[24m [4mflags[24m); - - [4mint[0m - [1mrtbl_set_prefix[22m([4mrtbl_t[24m [4mtable[24m, [4mconst[24m [4mchar[24m [4m*prefix[24m); - - [4mint[0m - [1mrtbl_set_separator[22m([4mrtbl_t[24m [4mtable[24m, [4mconst[24m [4mchar[24m [4m*separator[24m); - - [4mint[0m - [1mrtbl_format[22m([4mrtbl_t[24m [4mtable[24m, [4mFILE[24m, [4m*file"[24m); - -[1mDESCRIPTION[0m - This set of functions assemble a simple table consisting of rows and col- - umns, allowing it to be printed with certain options. Typical use would - be output from tools such as ls(1) or netstat(1), where you have a fixed - number of columns, but don't know the column widths before hand. - - A table is created with [1mrtbl_create[22m() and destroyed with [1mrtbl_destroy[22m(). - - Global flags on the table are set with [4mrtbl_set_flags[24m and retrieved with - [4mrtbl_get_flags[24m. At present the only defined flag is - RTBL_HEADER_STYLE_NONE which suppresses printing the header. - - Before adding data to the table, one or more columns need to be created. - This would normally be done with [1mrtbl_add_column_by_id[22m(), [4mcolumn_id[24m is - any number of your choice (it's used only to identify columns), - [4mcolumn_header[24m is the header to print at the top of the column, and [4mflags[0m - are flags specific to this column. Currently the only defined flag is - RTBL_ALIGN_RIGHT, aligning column entries to the right. Columns are - printed in the order they are added. - - There's also a way to add columns by column name with [1mrtbl_add_column[22m(), - but this is less flexible (you need unique header names), and is consid- - ered deprecated. - - To add data to a column you use [1mrtbl_add_column_entry_by_id[22m(), where the - [4mcolumn_id[24m is the same as when the column was added (adding data to a non- - existent column is undefined), and [4mcell_entry[24m is whatever string you wish - to include in that cell. It should not include newlines. For columns - added with [1mrtbl_add_column[22m() you must use [1mrtbl_add_column_entry[22m() in- - stead. - - [1mrtbl_new_row[22m() fills all columns with blank entries until they all have - the same number of rows. - - Each column can have a separate prefix and suffix, set with - [4mrtbl_set_column_affix_by_id[24m; [4mrtbl_set_column_prefix[24m allows setting the - prefix only by column name. In addition to this, columns may be separated - by a string set with [4mrtbl_set_separator[24m (by default columns are not - seprated by anything). - - The finished table is printed to [4mfile[24m with [4mrtbl_format[24m. - -[1mEXAMPLES[0m - This program: - - #include <stdio.h> - #include <rtbl.h> - int - main(int argc, char **argv) - { - rtbl_t table; - table = rtbl_create(); - rtbl_set_separator(table, " "); - rtbl_add_column_by_id(table, 0, "Column A", 0); - rtbl_add_column_by_id(table, 1, "Column B", RTBL_ALIGN_RIGHT); - rtbl_add_column_by_id(table, 2, "Column C", 0); - rtbl_add_column_entry_by_id(table, 0, "A-1"); - rtbl_add_column_entry_by_id(table, 0, "A-2"); - rtbl_add_column_entry_by_id(table, 0, "A-3"); - rtbl_add_column_entry_by_id(table, 1, "B-1"); - rtbl_add_column_entry_by_id(table, 2, "C-1"); - rtbl_add_column_entry_by_id(table, 2, "C-2"); - rtbl_add_column_entry_by_id(table, 1, "B-2"); - rtbl_add_column_entry_by_id(table, 1, "B-3"); - rtbl_add_column_entry_by_id(table, 2, "C-3"); - rtbl_add_column_entry_by_id(table, 0, "A-4"); - rtbl_new_row(table); - rtbl_add_column_entry_by_id(table, 1, "B-4"); - rtbl_new_row(table); - rtbl_add_column_entry_by_id(table, 2, "C-4"); - rtbl_new_row(table); - rtbl_format(table, stdout); - rtbl_destroy(table); - return 0; - } - - will output the following: - - Column A Column B Column C - A-1 B-1 C-1 - A-2 B-2 C-2 - A-3 B-3 C-3 - A-4 - B-4 - C-4 - -HEIMDAL June 26, 2004 HEIMDAL diff --git a/lib/roken/k_getpwnam.c b/lib/roken/secure_getenv.c index c0db757c43a0..d97d03dcd478 100644 --- a/lib/roken/k_getpwnam.c +++ b/lib/roken/secure_getenv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 2017 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,29 +33,15 @@ #include <config.h> +#include <errno.h> + #include "roken.h" -#ifdef HAVE_SHADOW_H -#include <shadow.h> -#endif +#include "secure_getenv.h" -ROKEN_LIB_FUNCTION struct passwd * ROKEN_LIB_CALL -k_getpwnam (const char *user) +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_secure_getenv(const char *name) { - struct passwd *p; - - p = getpwnam (user); -#if defined(HAVE_GETSPNAM) && defined(HAVE_STRUCT_SPWD) - if(p) - { - struct spwd *spwd; - - spwd = getspnam (user); - if (spwd) - p->pw_passwd = spwd->sp_pwdp; - endspent (); - } -#else - endpwent (); -#endif - return p; + if (issuid()) + return NULL; + return getenv(name); } diff --git a/lib/roken/secure_getenv.h b/lib/roken/secure_getenv.h new file mode 100644 index 000000000000..a3f536320729 --- /dev/null +++ b/lib/roken/secure_getenv.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL + rk_secure_getenv(const char *); + +#ifndef HAVE_SECURE_GETENV +#undef secure_getenv +#define secure_getenv(e) rk_secure_getenv(e) +#endif diff --git a/lib/roken/setprogname.c b/lib/roken/setprogname.c index 88a5f9bb4491..d24106abc2f9 100644 --- a/lib/roken/setprogname.c +++ b/lib/roken/setprogname.c @@ -74,7 +74,7 @@ setprogname(const char *argv0) strlwr(fn); ext = strrchr(fn, '.'); - if (ext != NULL && !strcmp(ext, ".exe")) + if (ext != NULL && strcmp(ext, ".exe") == 0) *ext = '\0'; __progname = fn; diff --git a/lib/roken/sleep.c b/lib/roken/sleep.c index a2599b90ebf0..53f416ec5605 100644 --- a/lib/roken/sleep.c +++ b/lib/roken/sleep.c @@ -41,7 +41,7 @@ ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL sleep(unsigned int seconds) { if (SleepEx(1000 * (DWORD) seconds, FALSE) != 0) - return -1; + return 1; /* XXX Should get time before and after */ return 0; } @@ -50,6 +50,6 @@ ROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL usleep(unsigned int useconds) { if (SleepEx((DWORD)(useconds / 1000), FALSE) != 0) - return -1; + return 1000; /* XXX Should get time before and after */ return 0; } diff --git a/lib/roken/snprintf.c b/lib/roken/snprintf.c index 9f6d3ca0412f..54018bae7982 100644 --- a/lib/roken/snprintf.c +++ b/lib/roken/snprintf.c @@ -309,7 +309,7 @@ append_char(struct snprintf_state *state, (*state->append_char) (state, ' '); ++len; } - return 0; + return len; } /* @@ -437,8 +437,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap) switch (c) { case 'c' : - append_char(state, va_arg(ap, int), width, flags); - ++len; + len += append_char(state, va_arg(ap, int), width, flags); break; case 's' : len += append_string(state, @@ -518,7 +517,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap) } case '\0' : --format; - /* FALLTHROUGH */ + HEIM_FALLTHROUGH; case '%' : (*state->append_char)(state, c); ++len; @@ -560,7 +559,7 @@ rk_snprintf (char *str, size_t sz, const char *format, ...) va_start(args, format); ret2 = vsprintf (tmp, format, args); va_end(args); - if (ret != ret2 || strcmp(str, tmp)) + if (ret != ret2 || strcmp(str, tmp) != 0) abort (); free (tmp); } @@ -592,7 +591,7 @@ rk_asprintf (char **ret, const char *format, ...) va_start(args, format); ret2 = vsprintf (tmp, format, args); va_end(args); - if (val != ret2 || strcmp(*ret, tmp)) + if (val != ret2 || strcmp(*ret, tmp) != 0) abort (); free (tmp); } @@ -621,7 +620,7 @@ rk_asnprintf (char **ret, size_t max_sz, const char *format, ...) abort (); ret2 = vsprintf (tmp, format, args); - if (val != ret2 || strcmp(*ret, tmp)) + if (val != ret2 || strcmp(*ret, tmp) != 0) abort (); free (tmp); } @@ -701,3 +700,30 @@ rk_vsnprintf (char *str, size_t sz, const char *format, va_list args) return ret; } #endif + +#if !defined(HAVE_EVASPRINTF) || defined(TEST_SNPRINTF) +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_evasprintf(const char *format, va_list args) +{ + char *s = NULL; + + if (vasprintf(&s, format, args) == -1 || s == NULL) + errx(1, "Out of memory"); + return s; +} +#endif + +#if !defined(HAVE_EASPRINTF) || defined(TEST_SNPRINTF) +ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL +rk_easprintf(const char *format, ...) +{ + va_list args; + char *s = NULL; + + va_start(args, format); + if (vasprintf(&s, format, args) == -1 || s == NULL) + errx(1, "Out of memory"); + va_end(args); + return s; +} +#endif diff --git a/lib/roken/socket.c b/lib/roken/socket.c index 0a8612557bce..5b578c89facf 100644 --- a/lib/roken/socket.c +++ b/lib/roken/socket.c @@ -221,16 +221,16 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_portrange (rk_socket_t sock, int restr, int af) { #if defined(IP_PORTRANGE) - if (af == AF_INET) { - int on = restr ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT; - setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on, sizeof(on)); - } + if (af == AF_INET) { + int on = restr ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT; + (void) setsockopt(sock, IPPROTO_IP, IP_PORTRANGE, &on, sizeof(on)); + } #endif #if defined(IPV6_PORTRANGE) - if (af == AF_INET6) { - int on = restr ? IPV6_PORTRANGE_HIGH : IPV6_PORTRANGE_DEFAULT; - setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on, sizeof(on)); - } + if (af == AF_INET6) { + int on = restr ? IPV6_PORTRANGE_HIGH : IPV6_PORTRANGE_DEFAULT; + (void) setsockopt(sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on, sizeof(on)); + } #endif } @@ -243,7 +243,7 @@ socket_set_debug (rk_socket_t sock) { #if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT) int on = 1; - setsockopt (sock, SOL_SOCKET, SO_DEBUG, (void *) &on, sizeof (on)); + (void) setsockopt(sock, SOL_SOCKET, SO_DEBUG, (void *) &on, sizeof (on)); #endif } @@ -255,7 +255,7 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_tos (rk_socket_t sock, int tos) { #if defined(IP_TOS) && defined(HAVE_SETSOCKOPT) - setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(int)); + (void) setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(int)); #endif } @@ -274,10 +274,11 @@ socket_set_nonblocking(rk_socket_t sock, int nonblock) flags |= O_NONBLOCK; else flags &= ~O_NONBLOCK; - fcntl(sock, F_SETFL, flags); + (void) fcntl(sock, F_SETFL, flags); #elif defined(FIOBIO) int flags = !!nonblock; - return ioctl(sock, FIOBIO, &flags); + + (void) ioctl(sock, FIOBIO, &flags); #endif } @@ -289,7 +290,8 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_reuseaddr (rk_socket_t sock, int val) { #if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT) - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val, sizeof(val)); + (void) setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val, + sizeof(val)); #endif } @@ -301,10 +303,22 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_ipv6only (rk_socket_t sock, int val) { #if defined(IPV6_V6ONLY) && defined(HAVE_SETSOCKOPT) - setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&val, sizeof(val)); + (void) setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&val, + sizeof(val)); #endif } +/* + * Set the that the `sock' keepalive setting. + */ + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +socket_set_keepalive(rk_socket_t sock, int val) +{ + (void) setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, + sizeof(val)); +} + /** * Create a file descriptor from a socket * diff --git a/lib/roken/stdint.hin b/lib/roken/stdint.hin index 4a8387a4e65c..e552d9dc62b6 100644 --- a/lib/roken/stdint.hin +++ b/lib/roken/stdint.hin @@ -5,8 +5,36 @@ extern "C" { #endif +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int int16_t; +typedef unsigned short int uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +#ifdef _MSC_VER +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else typedef long long int64_t; typedef unsigned long long uint64_t; +#endif + +#ifdef _MSC_VER +#include <intsafe.h> +#else +#define INT8_MAX 0x7F +#define INT8_MIN (-INT8_MAX - 1) +#define UINT8_MAX 0xFF +#define INT16_MAX 0x7FFF +#define INT16_MIN (-INT16_MAX - 1) +#define UINT16_MAX 0xFFFF +#define INT32_MAX 0x7FFFFFFF +#define INT32_MIN (-INT32_MIN - 1) +#define UINT32_MAX 0xFFFFFFFF +#define INT64_MAX 0x7FFFFFFFFFFFFFFFLL +#define INT64_MIN (-INT64_MAX - 1) +#define UINT64_MAX 0xFFFFFFFFFFFFFFFFLL +#endif #ifdef __cplusplus } diff --git a/lib/roken/strftime.c b/lib/roken/strftime.c index 447c1554337f..7be930755cad 100644 --- a/lib/roken/strftime.c +++ b/lib/roken/strftime.c @@ -36,6 +36,11 @@ #include "strpftime-test.h" #endif +#if defined(_WIN32) +# define timezone _timezone +# define tzname _tzname +#endif + static const char *abb_weekdays[] = { "Sun", "Mon", @@ -372,7 +377,7 @@ strftime (char *buf, size_t maxsize, const char *format, break; case '\0' : --format; - /* FALLTHROUGH */ + HEIM_FALLTHROUGH; case '%' : ret = snprintf (buf, maxsize - n, "%%"); diff --git a/lib/roken/strpftime-test.h b/lib/roken/strpftime-test.h index 5f9b23fda9db..157c77651af0 100644 --- a/lib/roken/strpftime-test.h +++ b/lib/roken/strpftime-test.h @@ -42,7 +42,13 @@ * these evil hacks */ +#ifdef strftime +#undef strftime +#endif #define strftime test_strftime +#ifdef strptime +#undef strptime +#endif #define strptime test_strptime ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL diff --git a/lib/roken/strpool.c b/lib/roken/strpool.c index 6e6a737bc630..032bae1dd23f 100644 --- a/lib/roken/strpool.c +++ b/lib/roken/strpool.c @@ -39,7 +39,8 @@ struct rk_strpool { char *str; - size_t len; + size_t len; /* strlen() of str */ + size_t sz; /* Allocated size */ }; /* @@ -49,7 +50,7 @@ struct rk_strpool { ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_strpoolfree(struct rk_strpool *p) { - if (p->str) { + if (p && p->str) { free(p->str); p->str = NULL; } @@ -64,29 +65,32 @@ ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL rk_strpoolprintf(struct rk_strpool *p, const char *fmt, ...) { va_list ap; - char *str, *str2; + char *str; int len; - if (p == NULL) { - p = malloc(sizeof(*p)); - if (p == NULL) - return NULL; - p->str = NULL; - p->len = 0; - } va_start(ap, fmt); len = vasprintf(&str, fmt, ap); va_end(ap); - if (str == NULL) { - rk_strpoolfree(p); - return NULL; - } - str2 = realloc(p->str, len + p->len + 1); - if (str2 == NULL) { - rk_strpoolfree(p); - return NULL; + if (str == NULL) + return rk_strpoolfree(p), NULL; + + if (p == NULL) { + if ((p = malloc(sizeof(*p))) == NULL) + return free(str), NULL; + p->str = str; + p->len = p->sz = len; + return p; + } /* else grow the buffer and append `str', but don't grow too fast */ + + if (len + p->len + 1 > p->sz) { + size_t sz = p->len + len + 9 + (p->sz >> 2); + char *str2; + + if ((str2 = realloc(p->str, sz)) == NULL) + return rk_strpoolfree(p), NULL; + p->str = str2; + p->sz = sz; } - p->str = str2; memcpy(p->str + p->len, str, len + 1); p->len += len; free(str); diff --git a/lib/roken/strptime.c b/lib/roken/strptime.c index 75c27a328773..b9345c083233 100644 --- a/lib/roken/strptime.c +++ b/lib/roken/strptime.c @@ -424,7 +424,7 @@ strptime (const char *buf, const char *format, struct tm *timeptr) abort (); case '\0' : --format; - /* FALLTHROUGH */ + HEIM_FALLTHROUGH; case '%' : if (*buf == '%') ++buf; diff --git a/lib/roken/strtoll.c b/lib/roken/strtoll.c index 2e038bf30d6c..96c1b250974d 100644 --- a/lib/roken/strtoll.c +++ b/lib/roken/strtoll.c @@ -59,6 +59,7 @@ strtoll(const char * nptr, char ** endptr, int base) { const char *s; unsigned long long acc; + long long ret = 0; char c; unsigned long long cutoff; int neg, any, cutlim; @@ -137,15 +138,18 @@ strtoll(const char * nptr, char ** endptr, int base) } } if (any < 0) { - acc = neg ? LLONG_MIN : LLONG_MAX; + ret = neg ? LLONG_MIN : LLONG_MAX; errno = ERANGE; } else if (!any) { noconv: errno = EINVAL; - } else if (neg) - acc = -acc; + } else if (neg) { + ret = -(long long)acc; + } else { + ret = acc; + } if (endptr != NULL) *endptr = (char *)(any ? s - 1 : nptr); - return (acc); + return ret; } #endif /* !HAVE_STRTOLL */ diff --git a/lib/roken/strtoull.c b/lib/roken/strtoull.c index 3befab552de5..0516e18f9135 100644 --- a/lib/roken/strtoull.c +++ b/lib/roken/strtoull.c @@ -121,7 +121,7 @@ strtoull(const char * nptr, char ** endptr, int base) noconv: errno = EINVAL; } else if (neg) - acc = -acc; + acc = -(long long)acc; if (endptr != NULL) *endptr = (char *)(any ? s - 1 : nptr); return (acc); diff --git a/lib/roken/test-auxval.c b/lib/roken/test-auxval.c new file mode 100644 index 000000000000..80ad9e08588e --- /dev/null +++ b/lib/roken/test-auxval.c @@ -0,0 +1,235 @@ +/* + * Copyright (c) 1999 - 2004 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <config.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <err.h> +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include "roken.h" +#include "getauxval.h" + +static void +check_secure_getenv(char **env) +{ + size_t i; + char *v, *p; + + for (i = 0; env[i] != NULL; i++) { + if ((v = strdup(env[i])) == NULL) + err(1, "could not allocate copy of %s", env[i]); + if ((p = strchr(v, '='))) { + *p = '\0'; + if (issuid() && rk_secure_getenv(v) != NULL) + err(1, "rk_secure_getenv() returned non-NULL when issuid()!"); + if (!issuid() && rk_secure_getenv(v) == NULL) + err(1, "rk_secure_getenv() returned NULL when !issuid()"); + } + free(v); + } +} + +static void +inject_suid(int suid) +{ +#if defined(AT_SECURE) || (defined(AT_EUID) && defined(AT_RUID) && defined(AT_EGID) && defined(AT_RGID)) + auxv_t e; +#ifdef AT_SECURE + unsigned long secure = suid ? 1 : 0; +#endif +#if defined(AT_EUID) && defined(AT_RUID) && defined(AT_EGID) && defined(AT_RGID) + unsigned long eid = suid ? 0 : 1000; + + /* Inject real UID and GID */ + e.a_un.a_val = 1000; + e.a_type = AT_UID; + if ((errno = rk_injectauxv(&e)) != 0) + err(1, "rk_injectauxv(AT_RUID) failed"); + e.a_type = AT_GID; + if ((errno = rk_injectauxv(&e)) != 0) + err(1, "rk_injectauxv(AT_RGID) failed"); + + /* Inject effective UID and GID */ + e.a_un.a_val = eid; + e.a_type = AT_EUID; + if ((errno = rk_injectauxv(&e)) != 0) + err(1, "rk_injectauxv(AT_EUID) failed"); + e.a_type = AT_EGID; + if ((errno = rk_injectauxv(&e)) != 0) + err(1, "rk_injectauxv(AT_RGID) failed"); +#endif + +#ifdef AT_SECURE + e.a_un.a_val = secure; + e.a_type = AT_SECURE; + if ((errno = rk_injectauxv(&e)) != 0) + err(1, "rk_injectauxv(AT_SECURE) failed"); +#endif + + return; +#else + warnx("No ELF auxv types to inject"); +#endif +} + +static +unsigned long +getprocauxval(unsigned long type) +{ + const auxv_t *e; + + if ((e = rk_getauxv(type)) == NULL) { + errno = ENOENT; + return 0; + } + return e->a_un.a_val; +} + +/* returns 1 if auxval type is handled specially by libc */ +static int +is_special_auxv_p(long type) +{ +#ifdef AT_HWCAP + if (type == AT_HWCAP) + return 1; +#endif +#ifdef AT_HWCAP2 + if (type == AT_HWCAP2) + return 1; +#endif + + return 0; +} + +int +main(int argc, char **argv, char **env) +{ + unsigned long max_t = 0; + unsigned long a[2]; + unsigned long v; + ssize_t bytes; + int am_suid = issuid(); + int fd; + + (void) argc; + (void) argv; + + if (getuid() == geteuid() && getgid() == getegid()) { + if (issuid()) + errx(1, "issuid() false positive? Check AT_SECURE?"); + } else { + if (!issuid()) + errx(1, "issuid() did not detect set-uid-ness!"); + } + + if ((fd = open("/proc/self/auxv", O_RDONLY)) == -1) + return 0; + + /* + * Check that for every ELF auxv entry in /proc/self/auxv we + * find the correct answer from the rk_get*auxval() functions. + */ + do { + bytes = read(fd, a, sizeof(a)); + if (bytes != sizeof(a)) { + if (bytes == -1) + err(1, "Error reading from /proc/self/auxv"); + if (bytes == 0) + warnx("Did not see terminator in /proc/self/auxv"); + else + warnx("Partial entry in /proc/self/auxv or test interrupted"); + (void) close(fd); + return 1; + } + if (a[0] > max_t) + max_t = a[0]; + if (a[0] == 0) { + if (a[1] != 0) + warnx("AT_NULL with non-zero value %lu?!", a[1]); + continue; + } else if (is_special_auxv_p(a[0])) + continue; + + errno = EACCES; + + if ((v = rk_getauxval(a[0])) != a[1]) + errx(1, "rk_getauxval(%lu) should have been %lu, was %lu", + a[0], a[1], v); + if (errno != EACCES) + errx(1, "rk_getauxval(%lu) did not preserve errno", a[0]); + + if ((v = getprocauxval(a[0])) != a[1]) + errx(1, "rk_getauxval(%lu) should have been %lu, was %lu", + a[0], a[1], v); + if (errno != EACCES) + errx(1, "rk_getauxv(%lu) did not preserve errno", a[0]); + + printf("auxv type %lu -> %lu\n", a[0], a[1]); + } while (a[0] != 0 || a[1] != 0); + + (void) close(fd); + if (max_t == 0) { + warnx("No entries in /proc/self/auxv or it is not available on this " + "system or this program is linked statically; cannot test " + "rk_getauxval()"); + return 0; + } + + errno = EACCES; + if ((v = rk_getauxval(max_t + 1)) != 0) + errx(1, "rk_getauxval((max_type_seen = %lu) + 1) should have been " + "0, was %lu", max_t, v); + if (errno != ENOENT) + errx(1, "rk_getauxval((max_type_seen = %lu) + 1) did not set " + "errno = ENOENT!", max_t); + + errno = EACCES; + if ((v = getprocauxval(max_t + 1)) != 0) + errx(1, "rk_getauxv((max_type_seen = %lu) + 1) should have been " + "0, was %lu", max_t, v); + if (errno != ENOENT) + errx(1, "rk_getauxv((max_type_seen = %lu) + 1) did not set " + "errno = ENOENT!", max_t); + + check_secure_getenv(env); + inject_suid(!am_suid); + if ((am_suid && issuid()) || (!am_suid && !issuid())) + errx(1, "rk_injectprocauxv() failed"); + check_secure_getenv(env); + + return 0; +} diff --git a/lib/roken/test-detach.c b/lib/roken/test-detach.c index 09434d8ab9e5..0f4636eb6f5e 100644 --- a/lib/roken/test-detach.c +++ b/lib/roken/test-detach.c @@ -50,14 +50,21 @@ int main(int argc, char **argv) { +/* + * XXXrcd: let's see how much further the tests get when we disable this + * on Windows. + */ +#ifndef WIN32 char *ends; long n; int fd = -1; + pid_t parent = getpid(); + pid_t child; - if (argc > 1) { - if (argc != 3) - errx(1, "Usage: test-detach [--daemon-child fd]"); - fprintf(stderr, "Child started (argv[1] = %s, argv[2] = %s)!\n", argv[1], argv[2]); + if (argc == 2 && strcmp(argv[1], "--reexec") != 0) + errx(1, "Usage: test-detach [--reexec] [--daemon-child FD]"); + if (argc == 3 || argc == 4) { + parent = getppid(); errno = 0; n = strtol(argv[2], &ends, 10); fd = n; @@ -66,11 +73,19 @@ int main(int argc, char **argv) if (n < 0 || ends == NULL || *ends != '\0' || n != fd) errx(1, "Usage: test-detach [--daemon-child fd]"); } else { - fprintf(stderr, "Parent started as %ld\n", (long)getpid()); - roken_detach_prep(argc, argv, "--daemon-child"); + if (argc == 2) + /* Make sure we re-exec on the child-side of fork() (not WIN32) */ + putenv("ROKEN_DETACH_USE_EXEC=1"); + fd = roken_detach_prep(argc, argv, "--daemon-child"); + if (fd == -1) + errx(1, "bad"); } - fprintf(stderr, "Now should be the child: %ld\n", (long)getpid()); + if (parent == getpid()) + errx(1, "detach prep failed"); + child = getpid(); roken_detach_finish(NULL, fd); + if (child != getpid()) + errx(1, "detach finish failed"); /* * These printfs will not appear: stderr will have been replaced * with /dev/null. @@ -79,4 +94,7 @@ int main(int argc, char **argv) sleep(5); fprintf(stderr, "Daemon child done\n"); return 0; +#else + return 0; +#endif } diff --git a/lib/roken/test-getuserinfo.c b/lib/roken/test-getuserinfo.c new file mode 100644 index 000000000000..4feae177aed6 --- /dev/null +++ b/lib/roken/test-getuserinfo.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2017 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef WIN32 +#include <err.h> +#endif +#include "roken.h" + +static void +print1(const char *name, const char *tabs, const char *s2) +{ + (void) printf("%s:%s%s\n", name, tabs, s2 ? s2 : "<NULL>"); +} + +int +main(void) +{ + char buf[MAX_PATH * 2]; +#ifndef WIN32 + char buf2[MAX_PATH * 2]; + int ret = 0; + if (!issuid() && getuid() != 0) { + const char *s = NULL; + const char *s2 = NULL; + + if (getenv("USER") != NULL && strlen(getenv("USER")) != 0 && + (s = roken_get_username(buf, sizeof(buf))) == NULL) { + warnx("roken_get_username() returned NULL but $USER is set"); + ret++; + } + if (getenv("USER") != NULL && strlen(getenv("USER")) != 0 && s && + strcmp(getenv("USER"), s) != 0) { + warnx("roken_get_username() != getenv(\"USER\")"); + ret++; + } + + if (getenv("HOME") != NULL && strlen(getenv("HOME")) != 0 && + (s = roken_get_homedir(buf, sizeof(buf))) == NULL) { + warnx("roken_get_homedir() returned NULL but $HOME is set"); + ret++; + } + if (getenv("HOME") != NULL && strlen(getenv("HOME")) != 0 && s && + strcmp(getenv("HOME"), s) != 0) { + warnx("roken_get_homedir() != getenv(\"HOME\")"); + ret++; + } + + if (getenv("HOME") != NULL && strlen(getenv("HOME")) != 0 && s && + (s2 = roken_get_appdatadir(buf, sizeof(buf))) == NULL) { + warnx("roken_get_appdatadir() returned NULL but $HOME is set " + "and roken_get_homedir() returned not-NULL"); + ret++; + } + if (getenv("HOME") != NULL && strlen(getenv("HOME")) != 0 && + s && s2 && strcmp(s, s2) != 0) { + warnx("roken_get_homedir() != roken_get_appdatadir()"); + ret++; + } + if (getenv("SHELL") != NULL && strlen(getenv("SHELL")) != 0 && + strcmp(getenv("SHELL"), roken_get_shell(buf, sizeof(buf))) != 0) { + warnx("roken_get_shell() != getenv(\"SHELL\")"); + ret++; + } + } +#endif + + print1("Username", "\t", roken_get_username(buf, sizeof(buf))); + print1("Loginname", "\t", roken_get_loginname(buf, sizeof(buf))); + print1("Home", "\t\t", roken_get_homedir(buf, sizeof(buf))); + print1("Appdatadir", "\t", roken_get_appdatadir(buf, sizeof(buf))); + print1("Shell", "\t\t", roken_get_shell(buf, sizeof(buf))); + +#ifndef WIN32 + if (!issuid() && getuid() != 0) { + const char *s, *s2; + + putenv("USER=h5lfoouser"); + putenv("HOME=/no/such/dir/h5lfoouser"); + putenv("SHELL=/no/such/shell"); + if ((s = roken_get_username(buf, sizeof(buf))) == NULL || + strcmp("h5lfoouser", s) != 0) { + warnx("roken_get_username() (%s) did not honor $USER", s); + ret++; + } + if ((s = roken_get_homedir(buf, sizeof(buf))) == NULL || + strcmp("/no/such/dir/h5lfoouser", s) != 0) { + warnx("roken_get_homedir() (%s) did not honor $HOME", s); + ret++; + } + s = roken_get_homedir(buf, sizeof(buf)); + s2 = roken_get_appdatadir(buf2, sizeof(buf2)); + if (strcmp(s, s2) != 0) { + warnx("roken_get_homedir() != roken_get_appdatadir() (%s)", + roken_get_appdatadir(buf, sizeof(buf))); + ret++; + } + if ((s = roken_get_shell(buf, sizeof(buf))) == NULL || + strcmp("/no/such/shell", s) != 0) { + warnx("roken_get_shell() (%s) did not honor $SHELL", s); + ret++; + } + } + return ret; +#endif + return 0; +} diff --git a/lib/roken/test-mini_inetd.c b/lib/roken/test-mini_inetd.c index 5afdf74ed8c9..7ab996ae8b4c 100644 --- a/lib/roken/test-mini_inetd.c +++ b/lib/roken/test-mini_inetd.c @@ -144,7 +144,7 @@ test_simple_echo_client(void) } if (rv != strlen(test_strings[i])) { - fprintf (stderr, "[%s] Data length mismatch %d != %d\n", prog, rv, strlen(test_strings[i])); + fprintf (stderr, "[%s] Data length mismatch %d != %zu\n", prog, rv, strlen(test_strings[i])); rk_closesocket(s); return 1; } @@ -195,7 +195,7 @@ test_simple_echo_socket(void) getprogname(), srv, rv); } - if (!strcmp(buf, "exit")) { + if (strcmp(buf, "exit") == 0) { fprintf(stderr, "[%s] Exiting...\n", prog); shutdown(s, SD_SEND); rk_closesocket(s); @@ -234,7 +234,7 @@ test_simple_echo(void) while (gets(buf)) { fprintf(stderr, "[%s] Received [%s]\n", prog, buf); - if (!strcmp(buf, "exit")) + if (strcmp(buf, "exit") == 0) return 0; /* simple echo */ @@ -253,7 +253,8 @@ do_client(void) { int rv = 0; - rk_SOCK_INIT(); + if (rk_SOCK_INIT()) + errx(1, "Failed to initialize sockets (%s)", strerror(rk_SOCK_ERRNO)); prog = "Client"; is_client = 1; @@ -272,7 +273,8 @@ do_server(void) { int rv = 0; - rk_SOCK_INIT(); + if (rk_SOCK_INIT()) + errx(1, "Failed to initialize sockets (%s)", strerror(rk_SOCK_ERRNO)); prog = "Server"; diff --git a/lib/roken/timeval.c b/lib/roken/timeval.c index 38b1f7ce9c34..71fdd009ff24 100644 --- a/lib/roken/timeval.c +++ b/lib/roken/timeval.c @@ -39,6 +39,93 @@ #include "roken.h" +ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL +rk_time_add(time_t t, time_t delta) +{ + if (delta == 0) + return t; + +#ifdef TIME_T_SIGNED + /* Signed overflow is UB in C */ +#if SIZEOF_TIME_T == 4 + if (t >= 0 && delta > 0 && INT32_MAX - t < delta) + /* Time left to hit INT32_MAX is less than what we want to add */ + return INT32_MAX; + else if (t == INT32_MIN && delta < 0) + /* Avoid computing -t when t == INT32_MIN! */ + return INT32_MIN; + else if (t < 0 && delta < 0 && INT32_MIN + (-t) > delta) + /* Time left to hit INT32_MIN is less than what we want to subtract */ + return INT32_MIN; + else + return t + delta; +#elif SIZEOF_TIME_T == 8 + if (t >= 0 && delta > 0 && INT64_MAX - t < delta) + return INT64_MAX; + else if (t == INT64_MIN && delta < 0) + /* Avoid computing -t when t == INT64_MIN! */ + return INT64_MIN; + else if (t < 0 && delta < 0 && INT64_MIN + (-t) > delta) + return INT64_MIN; + else + return t + delta; +#else +#error "Unexpected sizeof(time_t)" +#endif +#else + + /* Unsigned overflow is defined in C */ +#if SIZEOF_TIME_T == 4 + if (t + delta < t) + return UINT32_MAX; +#elif SIZEOF_TIME_T == 8 + if (t + delta < t) + return UINT64_MAX; +#else +#error "Unexpected sizeof(time_t)" +#endif + return t + delta; +#endif +} + +ROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL +rk_time_sub(time_t t, time_t delta) +{ + if (delta == 0) + return t; +#ifdef TIME_T_SIGNED + if (delta > 0) + return rk_time_add(t, -delta); +#if SIZEOF_TIME_T == 4 + if (delta == INT32_MIN) { + if (t < 0) { + t = t + INT32_MAX; + return t + 1; + } + return INT32_MAX; + } + /* Safe to compute -delta, so use rk_time_add() to add -delta */ + return rk_time_add(t, -delta); +#elif SIZEOF_TIME_T == 8 + if (delta == INT64_MIN) { + if (t < 0) { + t = t + INT64_MAX; + return t + 1; + } + return INT64_MAX; + } + return rk_time_add(t, -delta); +#else +#error "Unexpected sizeof(time_t)" +#endif +#else + /* Both t and delta are non-negative. */ + if (delta > t) + return 0; + return t - delta; +#endif +} + /* * Make `t1' consistent. */ @@ -47,11 +134,11 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL timevalfix(struct timeval *t1) { if (t1->tv_usec < 0) { - t1->tv_sec--; - t1->tv_usec += 1000000; + t1->tv_sec = rk_time_sub(t1->tv_sec, 1); + t1->tv_usec = 1000000; } if (t1->tv_usec >= 1000000) { - t1->tv_sec++; + t1->tv_sec = rk_time_add(t1->tv_sec, 1); t1->tv_usec -= 1000000; } } @@ -63,7 +150,7 @@ timevalfix(struct timeval *t1) ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL timevaladd(struct timeval *t1, const struct timeval *t2) { - t1->tv_sec += t2->tv_sec; + t1->tv_sec = rk_time_add(t1->tv_sec, t2->tv_sec); t1->tv_usec += t2->tv_usec; timevalfix(t1); } @@ -75,7 +162,125 @@ timevaladd(struct timeval *t1, const struct timeval *t2) ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL timevalsub(struct timeval *t1, const struct timeval *t2) { - t1->tv_sec -= t2->tv_sec; + t1->tv_sec = rk_time_sub(t1->tv_sec, t2->tv_sec); t1->tv_usec -= t2->tv_usec; timevalfix(t1); } + +#ifdef TEST +int +main(int argc, char **argv) +{ + time_t t, delta, r; + int e = 0; + + if (argc == 0) + return 0; /* Apparently POSIX and Linux allow this case */ + + argc--; + argv++; + + while (argc > 0) { + int64_t n; + time_t a; + char *ends; + + if (argc < 3) + errx(1, "Usage: [TIME +|- DELTA [== TIME]]"); + + errno = 0; + n = strtoll(argv[0], &ends, 0); + if (errno) + err(1, "Time value is invalid"); + if (*ends != '\0') + errx(1, "Time value is invalid"); + t = n; + + n = strtoll(argv[2], &ends, 0); + if (errno) + err(1, "Delta value is invalid"); + if (*ends != '\0') + errx(1, "Delta value is invalid"); + delta = n; + + if (argv[1][0] == '+' && argv[1][1] == '\0') + r = rk_time_add(t, delta); + else if (argv[1][0] == '-' && argv[1][1] == '\0') + r = rk_time_sub(t, delta); + else + errx(1, "Operator must be a + or a - arithmetic operator"); + + if (delta == 0 && r != t) { + warnx("%s %s %s != %s!", argv[0], argv[1], argv[2], argv[0]); + e = 1; + } + if (t == 0 && r != delta) { + warnx("%s %s %s != %s!", argv[0], argv[1], argv[2], argv[2]); + e = 1; + } + + if (argc > 4 && strcmp(argv[3], "==") == 0) { + n = strtoll(argv[4], &ends, 0); + if (errno) + err(1, "Time value is invalid"); + if (*ends != '\0') + errx(1, "Time value is invalid"); + a = n; + if (a != r) { + warnx("%s %s %s != %s!", argv[0], argv[1], argv[2], argv[4]); + e = 1; + } + argc -= 5; + argv += 5; + } else { +#ifdef TIME_T_SIGNED + printf("%s %s %s == %lld\n", argv[0], argv[1], argv[2], + (long long)r); +#else + printf("%s %s %s == %llu\n", argv[0], argv[1], argv[2], + (unsigned long long)r); +#endif + argc -= 3; + argv += 3; + } + } + +#define CHECK(e) do { if (!(e)) errx(1, "Expression not true: " #e "!"); } while (0) +#ifdef TIME_T_SIGNED +#if SIZEOF_TIME_T == 4 + CHECK(rk_time_add(INT32_MIN, -1) == INT32_MIN); + CHECK(rk_time_sub(INT32_MIN, 1) == INT32_MIN); + CHECK(rk_time_sub(-1, INT32_MAX) == INT32_MIN); + CHECK(rk_time_add(INT32_MAX, 0) == INT32_MAX); + CHECK(rk_time_add(INT32_MAX, 1) == INT32_MAX); + CHECK(rk_time_add(1, INT32_MAX) == INT32_MAX); + CHECK(rk_time_add(0, INT32_MAX) == INT32_MAX); +#elif SIZEOF_TIME_T == 8 + CHECK(rk_time_add(INT64_MIN, -1) == INT64_MIN); + CHECK(rk_time_sub(INT64_MIN, 1) == INT64_MIN); + CHECK(rk_time_sub(-1, INT64_MAX) == INT64_MIN); + CHECK(rk_time_add(INT64_MAX, 0) == INT64_MAX); + CHECK(rk_time_add(INT64_MAX, 1) == INT64_MAX); + CHECK(rk_time_add(1, INT64_MAX) == INT64_MAX); + CHECK(rk_time_add(0, INT64_MAX) == INT64_MAX); +#endif + CHECK(rk_time_add(0, -1) == -1); + CHECK(rk_time_sub(0, 1) == -1); +#else +#if SIZEOF_TIME_T == 4 + CHECK(rk_time_add(UINT32_MAX, 0) == UINT32_MAX); + CHECK(rk_time_add(UINT32_MAX, 1) == UINT32_MAX); + CHECK(rk_time_add(1, UINT32_MAX) == UINT32_MAX); + CHECK(rk_time_add(0, UINT32_MAX) == UINT32_MAX); +#elif SIZEOF_TIME_T == 8 + CHECK(rk_time_add(UINT64_MAX, 0) == UINT64_MAX); + CHECK(rk_time_add(UINT64_MAX, 1) == UINT64_MAX); + CHECK(rk_time_add(1, UINT64_MAX) == UINT64_MAX); + CHECK(rk_time_add(0, UINT64_MAX) == UINT64_MAX); +#endif +#endif + CHECK(rk_time_add(0, 1) == 1); + CHECK(rk_time_add(1, 0) == 1); + return e; +} +#endif diff --git a/lib/roken/tsearch.c b/lib/roken/tsearch.c index 0820bb62c0f8..e5df84633b92 100644 --- a/lib/roken/tsearch.c +++ b/lib/roken/tsearch.c @@ -24,10 +24,6 @@ typedef struct node { struct node *llink, *rlink; } node_t; -#ifndef __DECONST -#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) -#endif - /* * find or insert datum into search tree * @@ -61,7 +57,7 @@ rk_tsearch(const void *vkey, void **vrootp, if (q != 0) { /* make new node */ *rootp = q; /* link new node to old */ /* LINTED const castaway ok */ - q->key = __DECONST(void *, vkey); /* initialize new node */ + q->key = rk_UNCONST(vkey); /* initialize new node */ q->llink = q->rlink = NULL; } return q; diff --git a/lib/roken/verr.c b/lib/roken/verr.c index cd3cdf35ea6a..9201e6d35ee8 100644 --- a/lib/roken/verr.c +++ b/lib/roken/verr.c @@ -36,7 +36,7 @@ #include "roken.h" #include <err.h> -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL verr(int eval, const char *fmt, va_list ap) { rk_warnerr(1, fmt, ap); diff --git a/lib/roken/verrx.c b/lib/roken/verrx.c index 84645181c873..7b148a45fe8e 100644 --- a/lib/roken/verrx.c +++ b/lib/roken/verrx.c @@ -36,7 +36,7 @@ #include "roken.h" #include <err.h> -ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +ROKEN_LIB_NORETURN_FUNCTION void ROKEN_LIB_CALL verrx(int eval, const char *fmt, va_list ap) { rk_warnerr(0, fmt, ap); diff --git a/lib/roken/version-script.map b/lib/roken/version-script.map index ccd5925d24af..b48e06b9e6ae 100644 --- a/lib/roken/version-script.map +++ b/lib/roken/version-script.map @@ -1,8 +1,7 @@ -HEIMDAL_ROKEN_1.0 { +HEIMDAL_ROKEN_2.0 { global: arg_printusage; arg_printusage_i18n; - cgetcap; cgetclose; cgetmatch; cgetnum; @@ -12,15 +11,14 @@ HEIMDAL_ROKEN_1.0 { err; errx; free_getarg_strings; - get_default_username; + fseeko; + ftello; get_window_size; getarg; getnameinfo_verified; hex_decode; hex_encode; issuid; - k_getpwnam; - k_getpwuid; mini_inetd; mini_inetd_addrinfo; net_read; @@ -34,18 +32,19 @@ HEIMDAL_ROKEN_1.0 { print_units_table; rk_asnprintf; rk_asprintf; + rk_base32_decode; + rk_base32_encode; rk_base64_decode; rk_base64_encode; rk_bswap16; rk_bswap32; rk_bswap64; - rk_cgetent; - rk_cgetstr; rk_cloexec; + rk_cloexec_dir; rk_cloexec_file; - rk_cloexec_dir; - rk_cloexec_socket; + rk_cloexec_socket; rk_closefrom; + rk_clzll; rk_copyhostent; rk_dns_free_data; rk_dns_lookup; @@ -53,12 +52,14 @@ HEIMDAL_ROKEN_1.0 { rk_dns_string_to_type; rk_dns_type_to_string; rk_dumpdata; + rk_easprintf; rk_ecalloc; rk_emalloc; rk_eread; rk_erealloc; rk_esetenv; rk_estrdup; + rk_evasprintf; rk_ewrite; rk_flock; rk_fnmatch; @@ -68,6 +69,8 @@ HEIMDAL_ROKEN_1.0 { rk_freeifaddrs; rk_gai_strerror; rk_getaddrinfo; + rk_getauxv; + rk_getauxval; rk_getifaddrs; rk_getipnodebyaddr; rk_getipnodebyname; @@ -80,20 +83,31 @@ HEIMDAL_ROKEN_1.0 { rk_hostent_find_fqdn; rk_inet_ntop; rk_inet_pton; + rk_injectauxv; rk_localtime_r; + rk_memmem; rk_memset_s; + rk_mergesort; + rk_mergesort_r; rk_mkdir; + rk_mkdtemp; + rk_mkostemp; rk_mkstemp; + rk_parse_flags; + rk_parse_time; + rk_parse_units; rk_pid_file_delete; rk_pid_file_write; rk_pidfile; rk_pipe_execv; + rk_print_flags_table; + rk_print_time_table; + rk_print_units_table; rk_random_init; rk_read_environment; rk_readv; rk_realloc; - rk_strerror; - rk_strerror_r; + rk_secure_getenv; rk_setprogname; rk_simple_execle; rk_simple_execlp; @@ -109,13 +123,20 @@ HEIMDAL_ROKEN_1.0 { rk_socket_set_any; rk_socket_set_debug; rk_socket_set_ipv6only; + rk_socket_set_keepalive; rk_socket_set_nonblocking; rk_socket_set_port; rk_socket_set_portrange; rk_socket_set_reuseaddr; rk_socket_set_tos; rk_socket_sockaddr_size; + rk_strasvis; + rk_strasvisx; + rk_stravis; + rk_stravisx; rk_strcollect; + rk_strerror; + rk_strerror_r; rk_strftime; rk_strlcat; rk_strlcpy; @@ -126,6 +147,8 @@ HEIMDAL_ROKEN_1.0 { rk_strpoolfree; rk_strpoolprintf; rk_strptime; + rk_strrasvis; + rk_strrasvisx; rk_strsep_copy; rk_strsvis; rk_strsvisx; @@ -137,15 +160,23 @@ HEIMDAL_ROKEN_1.0 { rk_strvis; rk_strvisx; rk_svis; + rk_tdelete; + rk_tfind; rk_timegm; + rk_time_add; + rk_time_sub; rk_timevaladd; rk_timevalfix; rk_timevalsub; - rk_tdelete; - rk_tfind; rk_tsearch; rk_twalk; rk_undumpdata; + rk_undumptext; + rk_unparse_flags; + rk_unparse_time; + rk_unparse_time_approx; + rk_unparse_units; + rk_unparse_units_approx; rk_unvis; rk_vasnprintf; rk_vasprintf; @@ -157,13 +188,18 @@ HEIMDAL_ROKEN_1.0 { rk_warnerr; rk_xfree; roken_concat; - roken_detach_prep; roken_detach_finish; + roken_detach_prep; roken_getaddrinfo_hostspec2; roken_getaddrinfo_hostspec; roken_gethostby_setup; roken_gethostbyaddr; roken_gethostbyname; + roken_get_appdatadir; + roken_get_homedir; + roken_get_shell; + roken_get_username; + roken_get_loginname; roken_mconcat; roken_vconcat; roken_vmconcat; @@ -186,7 +222,6 @@ HEIMDAL_ROKEN_1.0 { signal; simple_execl; tm2time; - unix_verify_user; unparse_bytes; unparse_bytes_short; unparse_flags; diff --git a/lib/roken/versionsupport.h b/lib/roken/versionsupport.h new file mode 100644 index 000000000000..09adce3bf15a --- /dev/null +++ b/lib/roken/versionsupport.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2018-2019, AuriStor, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _VERSIONSUPPORT_H_ +#define _VERSIONSUPPORT_H_ 1 + +/* + * IsWindowsVersionOrGreater() is provided by Windows SDK 8.1 or greater. + * As AuriStorFS supports building with SDK 7.0 and greater we must + * provide our own. VerifyVersionInfoW() is present on Windows XP and + * later. + */ + +#ifndef _WIN32_WINNT_WIN7 +#define _WIN32_WINNT_WIN7 0x0601 +#endif + +#ifndef _WIN32_WINNT_WIN8 +#define _WIN32_WINNT_WIN8 0x0602 +#endif + +#ifndef _WIN32_WINNT_WINBLUE +#define _WIN32_WINNT_WINBLUE 0x0603 +#endif + +/* Based upon VersionHelpers.h */ +FORCEINLINE BOOL +IsWindowsVersionOrGreater(WORD wMajorVersion, + WORD wMinorVersion, + WORD wServicePackMajor) +{ + OSVERSIONINFOEXW osvi; + DWORDLONG dwlConditionMask = 0; + + dwlConditionMask = VerSetConditionMask(dwlConditionMask, + VER_MAJORVERSION, + VER_GREATER_EQUAL); + dwlConditionMask = VerSetConditionMask(dwlConditionMask, + VER_MINORVERSION, + VER_GREATER_EQUAL); + dwlConditionMask = VerSetConditionMask(dwlConditionMask, + VER_SERVICEPACKMAJOR, + VER_GREATER_EQUAL); + + memset(&osvi, 0, sizeof(OSVERSIONINFOEXW)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); + osvi.dwMajorVersion = wMajorVersion; + osvi.dwMinorVersion = wMinorVersion; + osvi.wServicePackMajor = wServicePackMajor; + + return VerifyVersionInfoW(&osvi, + (VER_MAJORVERSION | + VER_MINORVERSION | + VER_SERVICEPACKMAJOR), + dwlConditionMask); +} + +FORCEINLINE BOOL +IsWindowsXPOrGreater(VOID) +{ + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), + LOBYTE(_WIN32_WINNT_WINXP), + 0); +} + +FORCEINLINE BOOL +IsWindows7OrGreater(VOID) +{ + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), + LOBYTE(_WIN32_WINNT_WIN7), + 0); +} + +FORCEINLINE BOOL +IsWindows8OrGreater(VOID) +{ + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), + LOBYTE(_WIN32_WINNT_WIN8), + 0); +} + +FORCEINLINE BOOL +IsWindows8Point1OrGreater(VOID) +{ + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), + LOBYTE(_WIN32_WINNT_WINBLUE), + 0); +} + +#define IS_WINDOWS_VERSION_OR_GREATER_CACHED(fn) \ + \ +FORCEINLINE BOOL \ +fn##Cached(VOID) \ +{ \ + static LONG lIsVersionOrGreater = -1; \ + \ + if (lIsVersionOrGreater == -1) { \ + LONG lResult = fn(); \ + InterlockedCompareExchangeRelease(&lIsVersionOrGreater, \ + lResult, -1); \ + } \ + \ + return lIsVersionOrGreater == 1; \ +} + +IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindowsXPOrGreater) +IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindows7OrGreater) +IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindows8OrGreater) +IS_WINDOWS_VERSION_OR_GREATER_CACHED(IsWindows8Point1OrGreater) + +#endif /* _VERSIONSUPPORT_H_ */ diff --git a/lib/roken/vis-extras.h b/lib/roken/vis-extras.h new file mode 100644 index 000000000000..693edf8282e0 --- /dev/null +++ b/lib/roken/vis-extras.h @@ -0,0 +1,27 @@ +#ifndef _VIS_EXTRAS_H_ +#define _VIS_EXTRAS_H_ + +#include <roken.h> + +ROKEN_CPP_START + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL + rk_strasvis(char **, const char *, int, const char *); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL + rk_strasvisx(char **, const char *, size_t, int, const char *); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL + rk_strrasvis(char **, size_t *, const char *, int, const char *); + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL + rk_strrasvisx(char **, size_t *, const char *, size_t, int, const char *); + +ROKEN_CPP_END + +#define strasvis(a, b, c, d) rk_strasvis(a, b, c, d) +#define strasvisx(a, b, c, d) rk_strasvisx(a, b, c, d) +#define strrasvis(a, b, c, d) rk_strrasvis(a, b, c, d) +#define strrasvisx(a, b, c, d) rk_strrasvisx(a, b, c, d) + +#endif /* !_VIS_EXTRAS_H_ */ diff --git a/lib/roken/vis.c b/lib/roken/vis.c index 19ff29d95ca8..0fe44ae35023 100644 --- a/lib/roken/vis.c +++ b/lib/roken/vis.c @@ -55,48 +55,110 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if 1 +#define _DEFAULT_SOURCE #include <config.h> #include "roken.h" +#ifdef TEST +#include "getarg.h" +#endif #ifndef _DIAGASSERT #define _DIAGASSERT(X) #endif -#else /* heimdal */ -#include <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.37 2008/07/25 22:29:23 dsl Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#endif /* heimdal */ #include <sys/types.h> - #include <assert.h> #include <ctype.h> +#ifdef TEST +#include <err.h> +#endif +#include <errno.h> #include <limits.h> #include <stdio.h> #include <string.h> -#include <vis.h> #include <stdlib.h> - -#if 0 -#ifdef __weak_alias -__weak_alias(strsvis,_strsvis) -__weak_alias(strsvisx,_strsvisx) -__weak_alias(strvis,_strvis) -__weak_alias(strvisx,_strvisx) -__weak_alias(svis,_svis) -__weak_alias(vis,_vis) -#endif -#endif +#include <vis.h> #if !HAVE_VIS || !HAVE_SVIS #include <ctype.h> #include <limits.h> #include <stdio.h> #include <string.h> +#endif + +#if !HAVE_VIS || !HAVE_SVIS || TEST +/* + * We use makextralist() in main(), so we need it even if we have all the VIS + * routines in the host's C libraries. + */ + +/* 5 is for VIS_SP, VIS_TAB, VIS_NL, VIS_DQ, and VIS_NOSLASH */ +#define MAXEXTRAS (sizeof(char_glob) - 1 + sizeof(char_shell) - 1 + 5) + +#ifndef VIS_SHELL +#define VIS_SHELL 0x2000 +#endif +#ifndef VIS_GLOB +#define VIS_GLOB 0x0100 +#endif + +#ifndef VIS_SP +#define VIS_SP 0x0004 /* also encode space */ +#endif +#ifndef VIS_TAB +#define VIS_TAB 0x0008 /* also encode tab */ +#endif +#ifndef VIS_NL +#define VIS_NL 0x0010 /* also encode newline */ +#endif +#ifndef VIS_WHITE +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) +#endif +#ifndef VIS_SAFE +#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */ +#endif +#ifndef VIS_DQ +#define VIS_DQ 0x8000 /* also encode double quotes */ +#endif + + +/* + * Expand list of extra characters to not visually encode. + */ +static char * +makeextralist(int flags, const char *src) +{ + static const char char_glob[] = "*?[#"; + static const char char_shell[] = "'`\";&<>()|{}]\\$!^~"; + char *dst, *d; + size_t len; + + len = strlen(src); + if ((dst = d = calloc(1, len + MAXEXTRAS + 1)) == NULL) + return NULL; + + memcpy(dst, src, len); + d += len; + + if (flags & VIS_GLOB) { + memcpy(d, char_glob, sizeof(char_glob) - 1); + d += sizeof(char_glob) - 1; + } + if (flags & VIS_SHELL) { + memcpy(d, char_shell, sizeof(char_shell) - 1); + d += sizeof(char_shell) - 1; + } + + if (flags & VIS_SP) *d++ = ' '; + if (flags & VIS_TAB) *d++ = '\t'; + if (flags & VIS_NL) *d++ = '\n'; + if (flags & VIS_DQ) *d++ = '"'; + if ((flags & VIS_NOSLASH) == 0) *d++ = '\\'; + + return dst; +} +#endif +#if !HAVE_VIS || !HAVE_SVIS static char *do_svis(char *, int, int, int, const char *); #undef BELL @@ -119,40 +181,19 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_strsvisx (char *, const char *, size_t, int, const char *); - #define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') #define iswhite(c) (c == ' ' || c == '\t' || c == '\n') #define issafe(c) (c == '\b' || c == BELL || c == '\r') #define xtoa(c) "0123456789abcdef"[c] -#define MAXEXTRAS 5 - -#define MAKEEXTRALIST(flag, extra, orig_str) \ -do { \ - const char *orig = orig_str; \ - const char *o = orig; \ - char *e; \ - while (*o++) \ - continue; \ - extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \ - if (!extra) break; \ - for (o = orig, e = extra; (*e++ = *o++) != '\0';) \ - continue; \ - e--; \ - if (flag & VIS_SP) *e++ = ' '; \ - if (flag & VIS_TAB) *e++ = '\t'; \ - if (flag & VIS_NL) *e++ = '\n'; \ - if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \ - *e = '\0'; \ -} while (/*CONSTCOND*/0) - /* * This is do_hvis, for HTTP style (RFC 1808) */ static char * do_hvis(char *dst, int c, int flag, int nextc, const char *extra) { - if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { + if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL || + strchr(extra, c)) { *dst++ = '%'; *dst++ = xtoa(((unsigned int)c >> 4) & 0xf); *dst++ = xtoa((unsigned int)c & 0xf); @@ -256,7 +297,7 @@ rk_svis(char *dst, int c, int flag, int nextc, const char *extra) _DIAGASSERT(dst != NULL); _DIAGASSERT(extra != NULL); - MAKEEXTRALIST(flag, nextra, extra); + nextra = makeextralist(flag, extra); if (!nextra) { *dst = '\0'; /* can't create nextra, return "" */ return dst; @@ -298,7 +339,7 @@ rk_strsvis(char *dst, const char *csrc, int flag, const char *extra) _DIAGASSERT(dst != NULL); _DIAGASSERT(src != NULL); _DIAGASSERT(extra != NULL); - MAKEEXTRALIST(flag, nextra, extra); + nextra = makeextralist(flag, extra); if (!nextra) { *dst = '\0'; /* can't create nextra, return "" */ return 0; @@ -327,7 +368,7 @@ rk_strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra _DIAGASSERT(dst != NULL); _DIAGASSERT(src != NULL); _DIAGASSERT(extra != NULL); - MAKEEXTRALIST(flag, nextra, extra); + nextra = makeextralist(flag, extra); if (! nextra) { *dst = '\0'; /* can't create nextra, return "" */ return 0; @@ -336,12 +377,12 @@ rk_strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra if (flag & VIS_HTTPSTYLE) { for (start = dst; len > 0; len--) { c = *src++; - dst = do_hvis(dst, c, flag, len ? *src : '\0', nextra); + dst = do_hvis(dst, c, flag, *src, nextra); } } else { for (start = dst; len > 0; len--) { c = *src++; - dst = do_svis(dst, c, flag, len ? *src : '\0', nextra); + dst = do_svis(dst, c, flag, *src, nextra); } } free(nextra); @@ -350,6 +391,69 @@ rk_strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra } #endif +/* + * Heimdal innovations: functions that allocate or reallocate a destination + * buffer as needed. Based on OpenBSD's stravis(). + */ + +#include <vis-extras.h> + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_strasvis(char **out, const char *csrc, int flag, const char *extra) +{ + return rk_strasvisx(out, csrc, strlen(csrc), flag, extra); +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_strrasvis(char **out, size_t *outsz, const char *csrc, int flag, const char *extra) +{ + return rk_strrasvisx(out, outsz, csrc, strlen(csrc), flag, extra); +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_strasvisx(char **out, const char *csrc, size_t len, int flag, const char *extra) +{ + size_t sz = 0; + + *out = NULL; + return rk_strrasvisx(out, &sz, csrc, strlen(csrc), flag, extra); +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +rk_strrasvisx(char **out, + size_t *outsz, + const char *csrc, + size_t len, + int flag, + const char *extra) +{ + size_t want = 4 * len + 4; + size_t have = *outsz; + char *s = *out; + int r; + + _DIAGASSERT(dst != NULL); + _DIAGASSERT(src != NULL); + _DIAGASSERT(extra != NULL); + if (want < len || want > INT_MAX) { + errno = EOVERFLOW; + return -1; + } + if (have < want) { + if ((s = realloc(s, want)) == NULL) + return -1; + *outsz = want; + *out = s; + } + if (*out == NULL) { + errno = EINVAL; + return -1; + } + **out = '\0'; /* Makes source debugging nicer, that's all */ + r = strsvisx(*out, csrc, len, flag, extra); + return r; +} + #if !HAVE_VIS /* * vis - visually encode characters @@ -362,7 +466,7 @@ rk_vis(char *dst, int c, int flag, int nextc) _DIAGASSERT(dst != NULL); - MAKEEXTRALIST(flag, extra, ""); + extra = makeextralist(flag, ""); if (! extra) { *dst = '\0'; /* can't create extra, return "" */ return dst; @@ -393,7 +497,7 @@ rk_strvis(char *dst, const char *src, int flag) char *extra = NULL; int rv; - MAKEEXTRALIST(flag, extra, ""); + extra = makeextralist(flag, ""); if (!extra) { *dst = '\0'; /* can't create extra, return "" */ return 0; @@ -410,7 +514,7 @@ rk_strvisx(char *dst, const char *src, size_t len, int flag) char *extra = NULL; int rv; - MAKEEXTRALIST(flag, extra, ""); + extra = makeextralist(flag, ""); if (!extra) { *dst = '\0'; /* can't create extra, return "" */ return 0; @@ -420,3 +524,126 @@ rk_strvisx(char *dst, const char *src, size_t len, int flag) return rv; } #endif + +#ifdef TEST +static const char *extra_arg = ""; +static int cstyle_flag; +static int glob_flag; +static int help_flag; +static int http_flag; +static int httponly_flag; +static int line_flag; +static int octal_flag; +static int safe_flag; +static int shell_flag; +static int stdin_flag; +static int tab_flag; +static int whitespace_flag; + +/* + * The short options are compatible with a subset of the FreeBSD contrib + * vis(1). Heimdal additions have long option names only. + */ +static struct getargs args[] = { + { "c", 'C', arg_flag, &cstyle_flag, "C style", "C style" }, + { "extra", 'e', arg_string, &extra_arg, "also encode extra", "also encode extra"}, + { "glob", 'g', arg_flag, &glob_flag, "escape glob specials", "escape glob specials" }, + { "help", 0, arg_flag, &help_flag, "help", "help"}, + { "line", 0, arg_flag, &line_flag, "read and escape stdin without escaping newlines", NULL }, + { "octal", 'o', arg_flag, &octal_flag, "octal escape", "octal escape" }, + { "safe", 's', arg_flag, &safe_flag, "only encode \"unsafe\" characters", "only encode \"unsafe\" characters" }, + { "shell", 'S', arg_flag, &shell_flag, "encode shell meta-characters", "encode shell meta-characters" }, + { "stdin", 0, arg_flag, &stdin_flag, "read and escape stdin", NULL }, + { "tab", 't', arg_flag, &tab_flag, "encode tabs", "encode tabs" }, + { "url", 'h', arg_flag, &http_flag, "url escape", "url escape" }, + { "url-only", 0, arg_flag, &httponly_flag, "url escape", "url escape" }, + { "whitespace", 'w', arg_flag, &whitespace_flag, "encode whitespace", "encode whitespace" }, + { 0, 0, 0, 0, 0, 0} +}; +static size_t num_args = sizeof(args)/sizeof(args[0]); + +int +main(int argc, char **argv) +{ + size_t sz = 0; + char *nextra = NULL; + char *s = NULL; + int goptind = 0; + int flags = 0; + + setprogname("vis"); + if (getarg(args, num_args, argc, argv, &goptind) || help_flag) { + arg_printusage(args, num_args, NULL, "strings..."); + return help_flag ? 0 : 1; + } + + argc -= goptind; + argv += goptind; + + if (argc == 0 && !stdin_flag && !line_flag) { + arg_printusage(args, num_args, NULL, "strings..."); + return 1; + } + + if (http_flag && cstyle_flag) + errx(1, "--http and --cstyle are mutually exclusive"); + + flags |= cstyle_flag ? VIS_CSTYLE : 0; + flags |= http_flag ? VIS_HTTPSTYLE : 0; + flags |= httponly_flag ? VIS_HTTPSTYLE | VIS_NOESCAPE : 0; + flags |= octal_flag ? VIS_OCTAL : 0; + flags |= safe_flag ? VIS_SAFE : 0; + flags |= tab_flag ? VIS_TAB : 0; + flags |= whitespace_flag ? VIS_WHITE : 0; + + if ((nextra = makeextralist(flags, extra_arg)) == NULL) + err(1, "Out of memory"); + + while (argc) { + if (rk_strrasvis(&s, &sz, argv[0], flags, nextra) < 0) + err(2, "Out of memory"); + printf("%s\n", s); + argc--; + } + if (line_flag) { + ssize_t nbytes; + size_t linesz = 0; + char *line = NULL; + + while (!feof(stdin) && + (nbytes = getline(&line, &linesz, stdin)) > 0) { + const char *nl = ""; + + if (line[nbytes - 1] == '\n') { + line[--nbytes] = '\0'; + nl = "\n"; + } + + if (rk_strrasvisx(&s, &sz, line, nbytes, flags, nextra) < 0) + err(2, "Out of memory"); + printf("%s%s", s, nl); + } + fflush(stdout); + if (ferror(stdin)) + errx(2, "I/O error"); + } else if (stdin_flag) { + size_t nbytes; + char buf[2048 + 1]; + char vbuf[4 * (sizeof(buf) - 1) + 1]; + + while (!feof(stdin) && + (nbytes = fread(buf, 1, sizeof(buf) - 1, stdin))) { + buf[nbytes] = '\0'; + strsvis(vbuf, buf, flags, nextra); + printf("%s", vbuf); + } + fflush(stdout); + if (ferror(stdin)) + errx(2, "I/O error"); + } + + free(nextra); + free(s); + return 0; +} +#endif diff --git a/lib/roken/vis.hin b/lib/roken/vis.hin index 25d662a98022..f1027f524c77 100644 --- a/lib/roken/vis.hin +++ b/lib/roken/vis.hin @@ -51,24 +51,43 @@ /* * to select alternate encoding format */ -#define VIS_OCTAL 0x01 /* use octal \ddd format */ -#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */ +#define VIS_OCTAL 0x0001 /* use octal \ddd format */ +#define VIS_CSTYLE 0x0002 /* use \[nrft0..] where appropiate */ /* * to alter set of characters encoded (default is to encode all * non-graphic except space, tab, and newline). */ -#define VIS_SP 0x04 /* also encode space */ -#define VIS_TAB 0x08 /* also encode tab */ -#define VIS_NL 0x10 /* also encode newline */ -#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) -#define VIS_SAFE 0x20 /* only encode "unsafe" characters */ +#define VIS_SP 0x0004 /* also encode space */ +#define VIS_TAB 0x0008 /* also encode tab */ +#define VIS_NL 0x0010 /* also encode newline */ +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) +#define VIS_SAFE 0x0020 /* only encode "unsafe" characters */ +#define VIS_DQ 0x8000 /* also encode double quotes */ /* * other */ -#define VIS_NOSLASH 0x40 /* inhibit printing '\' */ -#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */ +#define VIS_NOSLASH 0x0040 /* inhibit printing '\' */ +#define VIS_HTTPSTYLE 0x0080 /* http-style escape % HEX HEX */ +#define VIS_HTTP1808 0x0080 /* http-style escape % hex hex */ +#define VIS_GLOB 0x0100 /* encode glob(3) magic characters */ +#if 0 +/* + * Not yet. FreeBSD calls 0x0400 VIS_HTTP1866, but if that means RFC1866, + * that's HTML 2.0, not HTTP. Argh. + */ +#define VIS_MIMESTYLE 0x0200 /* mime-style escape = HEX HEX */ +#define VIS_HTML1866 0x0400 /* HTML-style &#num; or &string; */ +#endif +#define VIS_NOESCAPE 0x0800 /* don't decode `\'; URL-encode only when given + * with VIS_HTTPSTYLE */ +#if 0 +#define _VIS_END 0x1000 /* for unvis */ +#endif +#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */ +#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL) +#define VIS_NOLOCALE 0x4000 /* encode using the C locale */ /* * unvis return codes diff --git a/lib/roken/warn.c b/lib/roken/warn.c index 09b9cf82e72c..e149c5653aa2 100644 --- a/lib/roken/warn.c +++ b/lib/roken/warn.c @@ -33,6 +33,7 @@ #include <config.h> +#include "roken.h" #include "err.h" void diff --git a/lib/roken/win32_version.c b/lib/roken/win32_version.c new file mode 100644 index 000000000000..faf05b8de5de --- /dev/null +++ b/lib/roken/win32_version.c @@ -0,0 +1,128 @@ +#include <config.h> +#include "roken.h" +#include <psapi.h> + +static DWORD +GetVersionInfo(CHAR *filename, CHAR *szOutput, DWORD dwOutput) +{ + DWORD dwVersionHandle; + LPVOID pVersionInfo = 0; + DWORD retval = 0; + LPDWORD pLangInfo = 0; + LPTSTR szVersion = 0; + UINT len = 0; + TCHAR szVerQ[] = TEXT("\\StringFileInfo\\12345678\\FileVersion"); + DWORD size = GetFileVersionInfoSize(filename, &dwVersionHandle); + + if (!size) + return GetLastError(); + + pVersionInfo = malloc(size); + if (!pVersionInfo) + return ERROR_NOT_ENOUGH_MEMORY; + + GetFileVersionInfo(filename, dwVersionHandle, size, pVersionInfo); + if (retval = GetLastError()) + goto cleanup; + + VerQueryValue(pVersionInfo, TEXT("\\VarFileInfo\\Translation"), + (LPVOID*)&pLangInfo, &len); + if (retval = GetLastError()) + goto cleanup; + + wsprintf(szVerQ, + TEXT("\\StringFileInfo\\%04x%04x\\FileVersion"), + LOWORD(*pLangInfo), HIWORD(*pLangInfo)); + + VerQueryValue(pVersionInfo, szVerQ, (LPVOID*)&szVersion, &len); + if (retval = GetLastError()) { + /* try again with language 409 since the old binaries were tagged wrong */ + wsprintf(szVerQ, + TEXT("\\StringFileInfo\\0409%04x\\FileVersion"), + HIWORD(*pLangInfo)); + + VerQueryValue(pVersionInfo, szVerQ, (LPVOID*)&szVersion, &len); + if (retval = GetLastError()) + goto cleanup; + } + snprintf(szOutput, dwOutput, TEXT("%s"), szVersion); + szOutput[dwOutput - 1] = 0; + + cleanup: + free(pVersionInfo); + + return retval; +} + +ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL +win32_getLibraryVersion(const char *libname, char **outname, char **outversion) +{ + CHAR modVersion[128]; + HMODULE hMods[1024]; + HANDLE hProcess; + DWORD cbNeeded; + unsigned int i; + int success = -1; + HINSTANCE hPSAPI; + DWORD (WINAPI *pGetModuleFileNameExA)(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize); + BOOL (WINAPI *pEnumProcessModules)(HANDLE hProcess, HMODULE* lphModule, DWORD cb, LPDWORD lpcbNeeded); + + if (outversion) + *outversion = NULL; + if (outname) + *outname = NULL; + + hPSAPI = LoadLibrary("psapi"); + if ( hPSAPI == NULL ) + return -1; + + if (((FARPROC) pGetModuleFileNameExA = + GetProcAddress( hPSAPI, "GetModuleFileNameExA" )) == NULL || + ((FARPROC) pEnumProcessModules = + GetProcAddress( hPSAPI, "EnumProcessModules" )) == NULL) + { + goto out; + } + + // Get a list of all the modules in this process. + hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, + FALSE, GetCurrentProcessId()); + + if (pEnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) + { + for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) + { + char szModName[2048]; + + // Get the full path to the module's file. + if (pGetModuleFileNameExA(hProcess, hMods[i], szModName, sizeof(szModName))) + { + CHAR checkName[1024]; + lstrcpy(checkName, szModName); + strlwr(checkName); + + if (strstr(checkName, libname)) { + if (GetVersionInfo(szModName, modVersion, sizeof(modVersion)) == 0) { + success = 0; + if (outversion) { + *outversion = strdup(modVersion); + if (*outversion == NULL) + success = -1; + } + if (outname) { + *outname = strdup(szModName); + if (*outname == NULL) + success = -1; + } + } + break; + } + } + } + } + CloseHandle(hProcess); + + out: + FreeLibrary(hPSAPI); + return success; +} diff --git a/lib/roken/write_pid.c b/lib/roken/write_pid.c index 25ee686c30dd..c01091236f2e 100644 --- a/lib/roken/write_pid.c +++ b/lib/roken/write_pid.c @@ -43,6 +43,8 @@ ROKEN_LIB_FUNCTION char * ROKEN_LIB_CALL pid_file_write(const char *progname) { const char *pidfile_dir = NULL; + const char *sep = "/"; + size_t pidfile_dir_len; char *ret = NULL; FILE *fp; @@ -53,12 +55,21 @@ pid_file_write(const char *progname) * * For now we use an environment variable. */ - if (!issuid()) - pidfile_dir = getenv("HEIM_PIDFILE_DIR"); + pidfile_dir = secure_getenv("HEIM_PIDFILE_DIR"); if (pidfile_dir == NULL) pidfile_dir = _PATH_VARRUN; - if (asprintf(&ret, "%s%s.pid", pidfile_dir, progname) < 0 || ret == NULL) + pidfile_dir_len = strlen(pidfile_dir); + if (pidfile_dir_len > 1 && + pidfile_dir[pidfile_dir_len - 1] == '/') + sep = ""; +#ifdef WIN32 + if (pidfile_dir_len > 1 && + pidfile_dir[pidfile_dir_len - 1] == '\\') + sep = ""; +#endif + + if (asprintf(&ret, "%s%s%s.pid", pidfile_dir, sep, progname) < 0 || ret == NULL) return NULL; fp = fopen(ret, "w"); if (fp == NULL) { |