All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] pull: various removals and few fixes
@ 2017-07-31 19:54 Sami Kerola
  2017-07-31 19:55 ` [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h Sami Kerola
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:54 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Hello,

Here's again rather random bunch of changes.  First I thought total lines
deleted would exceed lines added, but the agetty --compile-time addition
pushed the balance otherway around.  Oh well, that was a good try.

Perhaps the nicest change in this series is look(1) bash-completion update
that pushes tab completion to make the usability of the command on next
level.  Assuming you have system word lists installed this is pretty easy to
try, '.  bash-completion/look ; look zo<tab tab>' and you get list of
possibilities from Zoe to zorching.  The next level of look(1) improvements
should make optional [file] to be consumed from an environment variable, so
that bash-completion would play together with user preferred word list.  But
that's something for next time.

Rest of the changes I assume to be pretty straightforward to review, so
hopefully no need for lengthy text about them.

----------------------------------------------------------------
The following changes since commit 8df545592d73b67b0bf119732b52a5e4c0662ec4:
  build: use --runstatedir instead of --localstatedir (2017-07-31 15:24:46 +0200)
are available in the git repository at:
  git://github.com/kerolasa/lelux-utiliteetit.git 2017wk30
for you to fetch changes up to 7677b5b502afd0c9436ce684bc38a8339a64e916:
  agetty: fix invalid usage crash (2017-07-31 20:23:29 +0100)
----------------------------------------------------------------

Sami Kerola (9):
  chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h
  include: move pamfail.h to auth.c
  vipw: use explicit_bzero() to clear buffer after copy
  uuidparse: nil uuid have all bits set to zero
  libuuid: use access(2) when checking /dev/random availability
  bash-completion: look for look completions
  agetty: remove dead DO_DEVFS_FIDDLING code segment
  agetty: add --compile-time option
  agetty: fix invalid usage crash

 bash-completion/look          |  13 +-
 include/Makemodule.am         |   1 -
 include/pamfail.h             |  26 ----
 libuuid/src/gen_uuid.c        |   5 +-
 login-utils/Makemodule.am     |   7 +-
 login-utils/auth.c            |  21 ++-
 login-utils/auth.h            |  13 --
 login-utils/ch-common.h       |  17 +++
 login-utils/chfn.c            |   4 -
 login-utils/chsh.c            |   4 -
 login-utils/islocal.c         |   2 +-
 login-utils/islocal.h         |   1 -
 login-utils/libuser.c         |   3 +-
 login-utils/libuser.h         |  14 --
 login-utils/vipw.c            |   3 +
 misc-utils/uuidparse.c        |   5 +-
 term-utils/agetty.8           |   3 +
 term-utils/agetty.c           | 296 ++++++++++++++++++++++++++++++++++++------
 tests/expected/uuid/uuidparse |   6 +-
 19 files changed, 320 insertions(+), 124 deletions(-)
 delete mode 100644 include/pamfail.h
 delete mode 100644 login-utils/auth.h
 delete mode 100644 login-utils/islocal.h
 delete mode 100644 login-utils/libuser.h

-- 
2.13.3


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-08-01  9:27   ` Karel Zak
  2017-07-31 19:55 ` [PATCH 2/9] include: move pamfail.h to auth.c Sami Kerola
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Merging header files is fine.  Merging sources files ch-common.c is
bad idea due linking needs, and differences in licences.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/Makemodule.am |  7 ++-----
 login-utils/auth.c        |  2 +-
 login-utils/auth.h        | 13 -------------
 login-utils/ch-common.h   | 17 +++++++++++++++++
 login-utils/chfn.c        |  4 ----
 login-utils/chsh.c        |  4 ----
 login-utils/islocal.c     |  2 +-
 login-utils/islocal.h     |  1 -
 login-utils/libuser.c     |  3 +--
 login-utils/libuser.h     | 14 --------------
 10 files changed, 22 insertions(+), 45 deletions(-)
 delete mode 100644 login-utils/auth.h
 delete mode 100644 login-utils/islocal.h
 delete mode 100644 login-utils/libuser.h

diff --git a/login-utils/Makemodule.am b/login-utils/Makemodule.am
index 67a0c98ec..2cc91b658 100644
--- a/login-utils/Makemodule.am
+++ b/login-utils/Makemodule.am
@@ -90,20 +90,17 @@ if HAVE_LINUXPAM
 chfn_chsh_ldadd += -lpam_misc
 endif
 chfn_chsh_sources += \
-	login-utils/auth.c \
-	login-utils/auth.h
+	login-utils/auth.c
 endif # CHFN_CHSH_PASSWORD
 
 if HAVE_USER
 chfn_chsh_ldflags += $(LIBUSER_LIBS)
 chfn_chsh_cflags += $(LIBUSER_CFLAGS)
 chfn_chsh_sources+= \
-	login-utils/libuser.c \
-	login-utils/libuser.h
+	login-utils/libuser.c
 else
 chfn_chsh_sources += \
 	login-utils/islocal.c \
-	login-utils/islocal.h \
 	login-utils/setpwnam.c \
 	login-utils/setpwnam.h
 endif
diff --git a/login-utils/auth.c b/login-utils/auth.c
index aaf6c536b..68d4ea3b0 100644
--- a/login-utils/auth.c
+++ b/login-utils/auth.c
@@ -7,7 +7,7 @@
  *   there is no warranty.
  *
  */
-#include "auth.h"
+#include "ch-common.h"
 #include "pamfail.h"
 
 int auth_pam(const char *service_name, uid_t uid, const char *username)
diff --git a/login-utils/auth.h b/login-utils/auth.h
deleted file mode 100644
index bf7c36924..000000000
--- a/login-utils/auth.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- *   auth.h -- PAM authorization code, common between chsh and chfn
- *   (c) 2012 by Cody Maloney <cmaloney@theoreticalchaos.com>
- *
- *   this program is free software.  you can redistribute it and
- *   modify it under the terms of the gnu general public license.
- *   there is no warranty.
- *
- */
-
-#include <sys/types.h>
-
-extern int auth_pam(const char *service_name, uid_t uid, const char *username);
diff --git a/login-utils/ch-common.h b/login-utils/ch-common.h
index 7f70e50e1..e2b402cc2 100644
--- a/login-utils/ch-common.h
+++ b/login-utils/ch-common.h
@@ -1,6 +1,23 @@
 #ifndef UTIL_LINUX_CH_COMMON_H
 #define UTIL_LINUX_CH_COMMON_H
 
+#include <sys/types.h>
+
 extern int illegal_passwd_chars(const char *str);
+extern int is_local(const char *user);
+
+/*
+ *   Utilize libuser to set a user attribute
+ *   (c) 2012 by Cody Maloney <cmaloney@theoreticalchaos.com>
+ */
+
+extern int set_value_libuser(const char *service_name, const char *username,
+                        uid_t uid, const char *attr, const char *val);
+
+/*
+ *   PAM authorization code, common between chsh and chfn
+ *   (c) 2012 by Cody Maloney <cmaloney@theoreticalchaos.com>
+ */
+extern int auth_pam(const char *service_name, uid_t uid, const char *username);
 
 #endif	/* UTIL_LINUX_CH_COMMON */
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index c5312fa0c..d7d0d03f2 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -35,7 +35,6 @@
 #include "c.h"
 #include "env.h"
 #include "closestream.h"
-#include "islocal.h"
 #include "nls.h"
 #include "setpwnam.h"
 #include "strutils.h"
@@ -51,9 +50,6 @@
 
 #ifdef HAVE_LIBUSER
 # include <libuser/user.h>
-# include "libuser.h"
-#elif CHFN_CHSH_PASSWORD
-# include "auth.h"
 #endif
 
 #ifdef HAVE_LIBREADLINE
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index 4721c870e..cdbfbc405 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -35,7 +35,6 @@
 #include "c.h"
 #include "env.h"
 #include "closestream.h"
-#include "islocal.h"
 #include "nls.h"
 #include "pathnames.h"
 #include "setpwnam.h"
@@ -52,9 +51,6 @@
 
 #ifdef HAVE_LIBUSER
 # include <libuser/user.h>
-# include "libuser.h"
-#elif CHFN_CHSH_PASSWORD
-# include "auth.h"
 #endif
 
 #ifdef HAVE_LIBREADLINE
diff --git a/login-utils/islocal.c b/login-utils/islocal.c
index 7c4e775c1..5bfe61982 100644
--- a/login-utils/islocal.c
+++ b/login-utils/islocal.c
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 
 #include "closestream.h"
-#include "islocal.h"
+#include "ch-common.h"
 #include "nls.h"
 #include "pathnames.h"
 
diff --git a/login-utils/islocal.h b/login-utils/islocal.h
deleted file mode 100644
index 2c5879906..000000000
--- a/login-utils/islocal.h
+++ /dev/null
@@ -1 +0,0 @@
-extern int is_local(const char *user);
diff --git a/login-utils/libuser.c b/login-utils/libuser.c
index b11fadc1c..65538d7d4 100644
--- a/login-utils/libuser.c
+++ b/login-utils/libuser.c
@@ -8,13 +8,12 @@
  *
  */
 
-#include "libuser.h"
+#include "ch-common.h"
 
 #include <grp.h>
 #include <libuser/user.h>
 #include <unistd.h>
 
-#include "auth.h"
 #include "c.h"
 #include "nls.h"
 
diff --git a/login-utils/libuser.h b/login-utils/libuser.h
deleted file mode 100644
index 7454b997e..000000000
--- a/login-utils/libuser.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- *   libuser.h -- Utilize libuser to set a user attribute
- *   (c) 2012 by Cody Maloney <cmaloney@theoreticalchaos.com>
- *
- *   this program is free software.  you can redistribute it and
- *   modify it under the terms of the gnu general public license.
- *   there is no warranty.
- *
- */
-
-#include <sys/types.h>
-
-extern int set_value_libuser(const char *service_name, const char *username,
-			uid_t uid, const char *attr, const char *val);
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/9] include: move pamfail.h to auth.c
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
  2017-07-31 19:55 ` [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-07-31 19:55 ` [PATCH 3/9] vipw: use explicit_bzero() to clear buffer after copy Sami Kerola
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

This removes one small header file, and makes inline function to static to
only file it is used in.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 include/Makemodule.am |  1 -
 include/pamfail.h     | 26 --------------------------
 login-utils/auth.c    | 19 ++++++++++++++++++-
 3 files changed, 18 insertions(+), 28 deletions(-)
 delete mode 100644 include/pamfail.h

diff --git a/include/Makemodule.am b/include/Makemodule.am
index 237400b05..e9b1e3021 100644
--- a/include/Makemodule.am
+++ b/include/Makemodule.am
@@ -33,7 +33,6 @@ dist_noinst_HEADERS += \
 	include/nls.h \
 	include/optutils.h \
 	include/pager.h \
-	include/pamfail.h \
 	include/partx.h \
 	include/path.h \
 	include/pathnames.h \
diff --git a/include/pamfail.h b/include/pamfail.h
deleted file mode 100644
index bb83b9404..000000000
--- a/include/pamfail.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * No copyright is claimed.  This code is in the public domain; do with
- * it what you wish.
- *
- * Written by Karel Zak <kzak@redhat.com>
- */
-#ifndef UTIL_LINUX_PAMFAIL_H
-#include <security/pam_appl.h>
-#ifdef HAVE_SECURITY_PAM_MISC_H
-# include <security/pam_misc.h>
-#elif defined(HAVE_SECURITY_OPENPAM_H)
-# include <security/openpam.h>
-#endif
-#include "c.h"
-
-static inline int
-pam_fail_check(pam_handle_t *pamh, int retcode)
-{
-	if (retcode == PAM_SUCCESS)
-		return 0;
-	warnx("%s", pam_strerror(pamh, retcode));
-	pam_end(pamh, retcode);
-	return 1;
-}
-
-#endif /* UTIL_LINUX_PAMFAIL_H */
diff --git a/login-utils/auth.c b/login-utils/auth.c
index 68d4ea3b0..efbd5e8cb 100644
--- a/login-utils/auth.c
+++ b/login-utils/auth.c
@@ -7,8 +7,25 @@
  *   there is no warranty.
  *
  */
+
+#include <security/pam_appl.h>
+#ifdef HAVE_SECURITY_PAM_MISC_H
+# include <security/pam_misc.h>
+#elif defined(HAVE_SECURITY_OPENPAM_H)
+# include <security/openpam.h>
+#endif
+
+#include "c.h"
 #include "ch-common.h"
-#include "pamfail.h"
+
+static int pam_fail_check(pam_handle_t *pamh, int retcode)
+{
+	if (retcode == PAM_SUCCESS)
+		return 0;
+	warnx("%s", pam_strerror(pamh, retcode));
+	pam_end(pamh, retcode);
+	return 1;
+}
 
 int auth_pam(const char *service_name, uid_t uid, const char *username)
 {
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/9] vipw: use explicit_bzero() to clear buffer after copy
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
  2017-07-31 19:55 ` [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h Sami Kerola
  2017-07-31 19:55 ` [PATCH 2/9] include: move pamfail.h to auth.c Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-07-31 19:55 ` [PATCH 4/9] uuidparse: nil uuid have all bits set to zero Sami Kerola
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

This should make leaking end of /etc/shadow file more unlikely.

Notice that there is now way to tell to editors they should ensure none it
does not leak any buffers, drop cores, and so on, when editing sensitive
data.  In short this change is addressing the issue only partially.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/vipw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/login-utils/vipw.c b/login-utils/vipw.c
index 5999d8d15..b7650de8b 100644
--- a/login-utils/vipw.c
+++ b/login-utils/vipw.c
@@ -100,6 +100,9 @@ static void copyfile(int from, int to)
 
 	if (nr < 0)
 		pw_error(orig_file, 1, 1);
+#ifdef HAVE_EXPLICIT_BZERO
+	explicit_bzero(buf, sizeof(buf));
+#endif
 }
 
 static void pw_init(void)
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/9] uuidparse: nil uuid have all bits set to zero
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (2 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 3/9] vipw: use explicit_bzero() to clear buffer after copy Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-07-31 19:55 ` [PATCH 5/9] libuuid: use access(2) when checking /dev/random availability Sami Kerola
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The nil UUID is special form of UUID that is specified to have all 128 bits
set to zero.

Reference: https://tools.ietf.org/html/rfc4122#section-4.1.7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 misc-utils/uuidparse.c        | 5 ++++-
 tests/expected/uuid/uuidparse | 6 +++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/misc-utils/uuidparse.c b/misc-utils/uuidparse.c
index 49225ae2c..5fa34b23d 100644
--- a/misc-utils/uuidparse.c
+++ b/misc-utils/uuidparse.c
@@ -195,7 +195,10 @@ static void fill_table_row(struct libscols_table *tb, char const *const uuid)
 			}
 			switch (type) {
 			case 0:
-				str = xstrdup(_("nil"));
+				if (strspn(uuid, "0-") == 36)
+					str = xstrdup(_("nil"));
+				else
+					str = xstrdup(_("unknown"));
 				break;
 			case 1:
 				str = xstrdup(_("time-based"));
diff --git a/tests/expected/uuid/uuidparse b/tests/expected/uuid/uuidparse
index 7fc64bcd2..c4959be8d 100644
--- a/tests/expected/uuid/uuidparse
+++ b/tests/expected/uuid/uuidparse
@@ -6,20 +6,20 @@ UUID                                  VARIANT   TYPE       TIME
 00000000-0000-4000-0000-000000000000  NCS       random     
 00000000-0000-5000-0000-000000000000  NCS       sha1-based 
 00000000-0000-6000-0000-000000000000  NCS       unknown    
-00000000-0000-0000-8000-000000000000  DCE       nil        
+00000000-0000-0000-8000-000000000000  DCE       unknown    
 00000000-0000-2000-8000-000000000000  DCE       DCE        
 00000000-0000-3000-8000-000000000000  DCE       name-based 
 00000000-0000-4000-8000-000000000000  DCE       random     
 00000000-0000-5000-8000-000000000000  DCE       sha1-based 
 00000000-0000-6000-8000-000000000000  DCE       unknown    
-00000000-0000-0000-d000-000000000000  Microsoft nil        
+00000000-0000-0000-d000-000000000000  Microsoft unknown    
 00000000-0000-1000-d000-000000000000  Microsoft time-based 
 00000000-0000-2000-d000-000000000000  Microsoft DCE        
 00000000-0000-3000-d000-000000000000  Microsoft name-based 
 00000000-0000-4000-d000-000000000000  Microsoft random     
 00000000-0000-5000-d000-000000000000  Microsoft sha1-based 
 00000000-0000-6000-d000-000000000000  Microsoft unknown    
-00000000-0000-0000-f000-000000000000  other     nil        
+00000000-0000-0000-f000-000000000000  other     unknown    
 00000000-0000-1000-f000-000000000000  other     time-based 
 00000000-0000-2000-f000-000000000000  other     DCE        
 00000000-0000-3000-f000-000000000000  other     name-based 
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/9] libuuid: use access(2) when checking /dev/random availability
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (3 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 4/9] uuidparse: nil uuid have all bits set to zero Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-07-31 19:55 ` [PATCH 6/9] bash-completion: look for look completions Sami Kerola
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The access(2) is more lightwight than stat(2), and tells whether random
device(s) can be read or not, unlike the earlier stat() call.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 libuuid/src/gen_uuid.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index 21e361293..7dafcaeed 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -534,9 +534,8 @@ void uuid_generate_random(uuid_t out)
  */
 static int have_random_source(void)
 {
-	struct stat s;
-
-	return (!stat("/dev/random", &s) || !stat("/dev/urandom", &s));
+	return (access("/dev/random", R_OK) == 0 ||
+		access("/dev/urandom", R_OK) == 0);
 }
 
 
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/9] bash-completion: look for look completions
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (4 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 5/9] libuuid: use access(2) when checking /dev/random availability Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-07-31 19:55 ` [PATCH 7/9] agetty: remove dead DO_DEVFS_FIDDLING code segment Sami Kerola
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

The look(1) uses positional arguments, where first one is a word from
dictionary.  It is reasonable to assume most of the time people search from
system word lists so propose completions from there.  The second argument is
a dictionary file, that might invalidate the first input but that only
happens to users who have an idea what the want without bash-completion.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 bash-completion/look | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/bash-completion/look b/bash-completion/look
index 303a7565a..feafe2379 100644
--- a/bash-completion/look
+++ b/bash-completion/look
@@ -20,9 +20,16 @@ _look_module()
 			return 0
 			;;
 	esac
-	local IFS=$'\n'
-	compopt -o filenames
-	COMPREPLY=( $(compgen -f -- $cur) )
+	case $COMP_CWORD in
+		1)
+			COMPREPLY=( $(compgen -W "$(look "$cur")" -- $cur) )
+			;;
+		2)
+			local IFS=$'\n'
+			compopt -o filenames
+			COMPREPLY=( $(compgen -f -- $cur) )
+			;;
+	esac
 	return 0
 }
 complete -F _look_module look
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 7/9] agetty: remove dead DO_DEVFS_FIDDLING code segment
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (5 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 6/9] bash-completion: look for look completions Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-07-31 19:55 ` [PATCH 8/9] agetty: add --compile-time option Sami Kerola
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

There is no ./configure option to enable this, and it is unlikely any
distribution hot patching to enable fiddling when building package.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/agetty.c | 39 ---------------------------------------
 1 file changed, 39 deletions(-)

diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index cc0cc3f62..a95da6f3d 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -829,45 +829,6 @@ static void parse_args(int argc, char **argv, struct options *op)
 	if (argc > optind && argv[optind])
 		op->term = argv[optind];
 
-#ifdef DO_DEVFS_FIDDLING
-	/*
-	 * Some devfs junk, following Goswin Brederlow:
-	 *   turn ttyS<n> into tts/<n>
-	 *   turn tty<n> into vc/<n>
-	 * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=72241
-	 */
-	if (op->tty && strlen(op->tty) < 90) {
-		char dev_name[100];
-		struct stat st;
-
-		if (strncmp(op->tty, "ttyS", 4) == 0) {
-			strcpy(dev_name, "/dev/");
-			strcat(dev_name, op->tty);
-			if (stat(dev_name, &st) < 0) {
-				strcpy(dev_name, "/dev/tts/");
-				strcat(dev_name, op->tty + 4);
-				if (stat(dev_name, &st) == 0) {
-					op->tty = strdup(dev_name + 5);
-					if (!op->tty)
-						log_err(_("failed to allocate memory: %m"));
-				}
-			}
-		} else if (strncmp(op->tty, "tty", 3) == 0) {
-			strcpy(dev_name, "/dev/");
-			strncat(dev_name, op->tty, 90);
-			if (stat(dev_name, &st) < 0) {
-				strcpy(dev_name, "/dev/vc/");
-				strcat(dev_name, op->tty + 3);
-				if (stat(dev_name, &st) == 0) {
-					op->tty = strdup(dev_name + 5);
-					if (!op->tty)
-						log_err(_("failed to allocate memory: %m"));
-				}
-			}
-		}
-	}
-#endif				/* DO_DEVFS_FIDDLING */
-
 	debug("exiting parseargs\n");
 }
 
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 8/9] agetty: add --compile-time option
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (6 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 7/9] agetty: remove dead DO_DEVFS_FIDDLING code segment Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-08-01  9:41   ` Karel Zak
  2017-07-31 19:55 ` [PATCH 9/9] agetty: fix invalid usage crash Sami Kerola
  2017-08-07  7:54 ` [PATCH 0/9] pull: various removals and few fixes Karel Zak
  9 siblings, 1 reply; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

This command has the most compile time #ifdef code.  It is time to add an
option to print what was defined when the command was compiled, so that
debugging is easier.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/agetty.8 |   3 +
 term-utils/agetty.c | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 254 insertions(+)

diff --git a/term-utils/agetty.8 b/term-utils/agetty.8
index 23adff3b1..230c47cd5 100644
--- a/term-utils/agetty.8
+++ b/term-utils/agetty.8
@@ -281,6 +281,9 @@ if the user has not yet commenced logging in.  After doing so the command will
 exit.  This feature might be unsupported on systems without Linux
 .BR inotify (7).
 .TP
+\-\-compile\-time
+Display compile time definitions.
+.TP
 \-\-version
 Display version information and exit.
 .TP
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index a95da6f3d..f06b9fc6e 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -309,6 +309,7 @@ static void termio_final(struct options *op,
 static int caps_lock(char *s);
 static speed_t bcode(char *s);
 static void usage(void) __attribute__((__noreturn__));
+static void compile_time(void) __attribute__((__noreturn__));
 static void log_err(const char *, ...) __attribute__((__noreturn__))
 			       __attribute__((__format__(printf, 1, 2)));
 static void log_warn (const char *, ...)
@@ -632,6 +633,7 @@ static void parse_args(int argc, char **argv, struct options *op)
 		ERASE_CHARS_OPTION,
 		KILL_CHARS_OPTION,
 		RELOAD_OPTION,
+		COMPILE_TIME_OPTION,
 	};
 	const struct option longopts[] = {
 		{  "8bits",	     no_argument,	 NULL,  '8'  },
@@ -668,6 +670,7 @@ static void parse_args(int argc, char **argv, struct options *op)
 		{  "help",	     no_argument,	 NULL,  HELP_OPTION     },
 		{  "erase-chars",    required_argument,  NULL,  ERASE_CHARS_OPTION },
 		{  "kill-chars",     required_argument,  NULL,  KILL_CHARS_OPTION },
+		{  "compile-time",   no_argument,	 NULL,	COMPILE_TIME_OPTION },
 		{ NULL, 0, NULL, 0 }
 	};
 
@@ -784,6 +787,8 @@ static void parse_args(int argc, char **argv, struct options *op)
 		case RELOAD_OPTION:
 			reload_agettys();
 			exit(EXIT_SUCCESS);
+		case COMPILE_TIME_OPTION:
+			compile_time();
 		case VERSION_OPTION:
 			printf(UTIL_LINUX_VERSION);
 			exit(EXIT_SUCCESS);
@@ -2073,6 +2078,7 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(_("     --delay <number>       sleep seconds before prompt\n"), out);
 	fputs(_("     --nice <number>        run login with this priority\n"), out);
 	fputs(_("     --reload               reload prompts on running agetty instances\n"), out);
+	printf( "     --compile-time         display what was defined during compile time\n");
 	printf( "     --help                 %s\n", USAGE_OPTSTR_HELP);
 	printf( "     --version              %s\n", USAGE_OPTSTR_VERSION);
 	printf(USAGE_MAN_TAIL("agetty(8)"));
@@ -2080,6 +2086,251 @@ static void __attribute__((__noreturn__)) usage(void)
 	exit(EXIT_SUCCESS);
 }
 
+static void __attribute__((__noreturn__)) compile_time(void)
+{
+#ifdef B19200
+printf("%-30s: defined\n", "B19200");
+#else
+printf("%-30s: not in use\n", "B19200");
+#endif
+
+#ifdef B38400
+printf("%-30s: defined\n", "B38400");
+#else
+printf("%-30s: not in use\n", "B38400");
+#endif
+
+#ifdef B57600
+printf("%-30s: defined\n", "B57600");
+#else
+printf("%-30s: not in use\n", "B57600");
+#endif
+
+#ifdef B115200
+printf("%-30s: defined\n", "B115200");
+#else
+printf("%-30s: not in use\n", "B115200");
+#endif
+
+#ifdef B230400
+printf("%-30s: defined\n", "B230400");
+#else
+printf("%-30s: not in use\n", "B230400");
+#endif
+
+#ifdef B460800
+printf("%-30s: defined\n", "B460800");
+#else
+printf("%-30s: not in use\n", "B460800");
+#endif
+
+#ifdef B500000
+printf("%-30s: defined\n", "B500000");
+#else
+printf("%-30s: not in use\n", "B500000");
+#endif
+
+#ifdef B576000
+printf("%-30s: defined\n", "B576000");
+#else
+printf("%-30s: not in use\n", "B576000");
+#endif
+
+#ifdef B921600
+printf("%-30s: defined\n", "B921600");
+#else
+printf("%-30s: not in use\n", "B921600");
+#endif
+
+#ifdef B1000000
+printf("%-30s: defined\n", "B1000000");
+#else
+printf("%-30s: not in use\n", "B1000000");
+#endif
+
+#ifdef B1152000
+printf("%-30s: defined\n", "B1152000");
+#else
+printf("%-30s: not in use\n", "B1152000");
+#endif
+
+#ifdef B1500000
+printf("%-30s: defined\n", "B1500000");
+#else
+printf("%-30s: not in use\n", "B1500000");
+#endif
+
+#ifdef B2000000
+printf("%-30s: defined\n", "B2000000");
+#else
+printf("%-30s: not in use\n", "B2000000");
+#endif
+
+#ifdef B2500000
+printf("%-30s: defined\n", "B2500000");
+#else
+printf("%-30s: not in use\n", "B2500000");
+#endif
+
+#ifdef B3000000
+printf("%-30s: defined\n", "B3000000");
+#else
+printf("%-30s: not in use\n", "B3000000");
+#endif
+
+#ifdef B3500000
+printf("%-30s: defined\n", "B3500000");
+#else
+printf("%-30s: not in use\n", "B3500000");
+#endif
+
+#ifdef B4000000
+printf("%-30s: defined\n", "B4000000");
+#else
+printf("%-30s: not in use\n", "B4000000");
+#endif
+
+#ifdef AGETTY_RELOAD
+printf("%-30s: defined\n", "AGETTY_RELOAD");
+#else
+printf("%-30s: not in use\n", "AGETTY_RELOAD");
+#endif
+
+#ifdef CRTSCTS
+printf("%-30s: defined\n", "CRTSCTS");
+#else
+printf("%-30s: not in use\n", "CRTSCTS");
+#endif
+
+#ifdef DEBUGGING
+printf("%-30s: defined\n", "DEBUGGING");
+#else
+printf("%-30s: not in use\n", "DEBUGGING");
+#endif
+
+#ifdef HAVE_GETDOMAINNAME
+printf("%-30s: defined\n", "HAVE_GETDOMAINNAME");
+#else
+printf("%-30s: not in use\n", "HAVE_GETDOMAINNAME");
+#endif
+
+#ifdef HAVE_LIBUTIL_H
+printf("%-30s: defined\n", "HAVE_LIBUTIL_H");
+#else
+printf("%-30s: not in use\n", "HAVE_LIBUTIL_H");
+#endif
+
+#ifdef HAVE_STRUCT_TERMIOS_C_LINE
+printf("%-30s: defined\n", "HAVE_STRUCT_TERMIOS_C_LINE");
+#else
+printf("%-30s: not in use\n", "HAVE_STRUCT_TERMIOS_C_LINE");
+#endif
+
+#ifdef HAVE_SYS_PARAM_H
+printf("%-30s: defined\n", "HAVE_SYS_PARAM_H");
+#else
+printf("%-30s: not in use\n", "HAVE_SYS_PARAM_H");
+#endif
+
+#ifdef HAVE_UTMP_H
+printf("%-30s: defined\n", "HAVE_UTMP_H");
+#else
+printf("%-30s: not in use\n", "HAVE_UTMP_H");
+#endif
+
+#ifdef HAVE_WIDECHAR
+printf("%-30s: defined\n", "HAVE_WIDECHAR");
+#else
+printf("%-30s: not in use\n", "HAVE_WIDECHAR");
+#endif
+
+#ifdef ISSUE
+printf("%-30s: defined\n", "ISSUE");
+#else
+printf("%-30s: not in use\n", "ISSUE");
+#endif
+
+#ifdef IUCLC
+printf("%-30s: defined\n", "IUCLC");
+#else
+printf("%-30s: not in use\n", "IUCLC");
+#endif
+
+#ifdef IUTF8
+printf("%-30s: defined\n", "IUTF8");
+#else
+printf("%-30s: not in use\n", "IUTF8");
+#endif
+
+#ifdef KDGKBLED
+printf("%-30s: defined\n", "KDGKBLED");
+#else
+printf("%-30s: not in use\n", "KDGKBLED");
+#endif
+
+#ifdef KDGKBMODE
+printf("%-30s: defined\n", "KDGKBMODE");
+#else
+printf("%-30s: not in use\n", "KDGKBMODE");
+#endif
+
+#ifdef K_RAW
+printf("%-30s: defined\n", "K_RAW");
+#else
+printf("%-30s: not in use\n", "K_RAW");
+#endif
+
+#ifdef LOGIN_PROCESS
+printf("%-30s: defined\n", "LOGIN_PROCESS");
+#else
+printf("%-30s: not in use\n", "LOGIN_PROCESS");
+#endif
+
+#ifdef OLCUC
+printf("%-30s: defined\n", "OLCUC");
+#else
+printf("%-30s: not in use\n", "OLCUC");
+#endif
+
+#ifdef SYSV_STYLE
+printf("%-30s: defined\n", "SYSV_STYLE");
+#else
+printf("%-30s: not in use\n", "SYSV_STYLE");
+#endif
+
+#ifdef USE_PLYMOUTH_SUPPORT
+printf("%-30s: defined\n", "USE_PLYMOUTH_SUPPORT");
+#else
+printf("%-30s: not in use\n", "USE_PLYMOUTH_SUPPORT");
+#endif
+
+#ifdef USE_SYSLOG
+printf("%-30s: defined\n", "USE_SYSLOG");
+#else
+printf("%-30s: not in use\n", "USE_SYSLOG");
+#endif
+
+#ifdef XCASE
+printf("%-30s: defined\n", "XCASE");
+#else
+printf("%-30s: not in use\n", "XCASE");
+#endif
+
+#ifdef __FreeBSD_kernel__
+printf("%-30s: defined\n", "__FreeBSD_kernel__");
+#else
+printf("%-30s: not in use\n", "__FreeBSD_kernel__");
+#endif
+
+#ifdef __linux__
+printf("%-30s: defined\n", "__linux__");
+#else
+printf("%-30s: not in use\n", "__linux__");
+#endif
+
+	exit(EXIT_SUCCESS);
+}
+
 /*
  * Helper function reports errors to console or syslog.
  * Will be used by log_err() and log_warn() therefore
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 9/9] agetty: fix invalid usage crash
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (7 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 8/9] agetty: add --compile-time option Sami Kerola
@ 2017-07-31 19:55 ` Sami Kerola
  2017-08-01  9:42   ` Karel Zak
  2017-08-07  7:54 ` [PATCH 0/9] pull: various removals and few fixes Karel Zak
  9 siblings, 1 reply; 17+ messages in thread
From: Sami Kerola @ 2017-07-31 19:55 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

$ agetty
agetty: not enough arguments: Success
Segmentation fault (core dumped)

Reference: 9325dbfd2018b2a3b510617f4aa13777fbbe23c3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/agetty.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index f06b9fc6e..d9e9548fa 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -803,7 +803,8 @@ static void parse_args(int argc, char **argv, struct options *op)
 
 	if (argc < optind + 1) {
 		log_warn(_("not enough arguments"));
-		warn(_("not enough arguments"));
+		warnx(_("not enough arguments"));
+		errtryhelp(EXIT_FAILURE);
 	}
 
 	/* Accept "tty", "baudrate tty", and "tty baudrate". */
@@ -812,7 +813,8 @@ static void parse_args(int argc, char **argv, struct options *op)
 		parse_speeds(op, argv[optind++]);
 		if (argc < optind + 1) {
 			log_warn(_("not enough arguments"));
-			warn(_("not enough arguments"));
+			warnx(_("not enough arguments"));
+			exit(EXIT_FAILURE);
 		}
 		op->tty = argv[optind++];
 	} else {
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h
  2017-07-31 19:55 ` [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h Sami Kerola
@ 2017-08-01  9:27   ` Karel Zak
  2017-08-05 16:33     ` Sami Kerola
  0 siblings, 1 reply; 17+ messages in thread
From: Karel Zak @ 2017-08-01  9:27 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jul 31, 2017 at 08:55:00PM +0100, Sami Kerola wrote:
> diff --git a/login-utils/Makemodule.am b/login-utils/Makemodule.am
> index 67a0c98ec..2cc91b658 100644
> --- a/login-utils/Makemodule.am
> +++ b/login-utils/Makemodule.am
> @@ -90,20 +90,17 @@ if HAVE_LINUXPAM
>  chfn_chsh_ldadd += -lpam_misc
>  endif
>  chfn_chsh_sources += \
> -	login-utils/auth.c \
> -	login-utils/auth.h
> +	login-utils/auth.c
>  endif # CHFN_CHSH_PASSWORD
>  
>  if HAVE_USER
>  chfn_chsh_ldflags += $(LIBUSER_LIBS)
>  chfn_chsh_cflags += $(LIBUSER_CFLAGS)
>  chfn_chsh_sources+= \
> -	login-utils/libuser.c \
> -	login-utils/libuser.h
> +	login-utils/libuser.c
>  else
>  chfn_chsh_sources += \
>  	login-utils/islocal.c \
> -	login-utils/islocal.h \
>  	login-utils/setpwnam.c \
>  	login-utils/setpwnam.h
>  endif

seems nowhere in the Makefile is our new ch-common.h

> --- a/login-utils/chfn.c
> +++ b/login-utils/chfn.c
> @@ -35,7 +35,6 @@
>  #include "c.h"
>  #include "env.h"
>  #include "closestream.h"
> -#include "islocal.h"
>  #include "nls.h"
>  #include "setpwnam.h"
>  #include "strutils.h"
> @@ -51,9 +50,6 @@
>  
>  #ifdef HAVE_LIBUSER
>  # include <libuser/user.h>
> -# include "libuser.h"
> -#elif CHFN_CHSH_PASSWORD
> -# include "auth.h"
>  #endif

It would be better to include libuser in the ch-common.h
if the function the header file depends on the library.


Frankly, I'm not sure if this patch improves readability of the code.
Now we have to ways (pam and libuser) and both is pretty separated by
.c and .h files. Not sure if merge it makes it better.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 8/9] agetty: add --compile-time option
  2017-07-31 19:55 ` [PATCH 8/9] agetty: add --compile-time option Sami Kerola
@ 2017-08-01  9:41   ` Karel Zak
  2017-08-05 16:44     ` Sami Kerola
  0 siblings, 1 reply; 17+ messages in thread
From: Karel Zak @ 2017-08-01  9:41 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jul 31, 2017 at 08:55:07PM +0100, Sami Kerola wrote:
> This command has the most compile time #ifdef code.  It is time to add an
> option to print what was defined when the command was compiled, so that
> debugging is easier.
> 
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  term-utils/agetty.8 |   3 +
>  term-utils/agetty.c | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 254 insertions(+)
> 
> diff --git a/term-utils/agetty.8 b/term-utils/agetty.8
> index 23adff3b1..230c47cd5 100644
> --- a/term-utils/agetty.8
> +++ b/term-utils/agetty.8
> @@ -281,6 +281,9 @@ if the user has not yet commenced logging in.  After doing so the command will
>  exit.  This feature might be unsupported on systems without Linux
>  .BR inotify (7).
>  .TP
> +\-\-compile\-time
> +Display compile time definitions.

I don't like the option name ;-)

> +static void __attribute__((__noreturn__)) compile_time(void)
> +{
> +#ifdef B19200
> +printf("%-30s: defined\n", "B19200");
> +#else
> +printf("%-30s: not in use\n", "B19200");
> +#endif

This is overkill. I can imagine --list-speeds to list built-in speeds
in format "<speed>\n"

static cost char *speeds[] = {
#ifdef B19200
    "B19200",
#endif
};

... and so on.

> +#ifdef AGETTY_RELOAD
> +printf("%-30s: defined\n", "AGETTY_RELOAD");
> +#else
> +printf("%-30s: not in use\n", "AGETTY_RELOAD");
> +#endif

For this purpose we can use --version, see for example mount:

 $ mount -V
 mount from util-linux 2.28.2 (libmount 2.28.2: selinux, btrfs, force-mountinfo, assert, debug)

the same we can use for agetty to list *really important* enabled
features, for example:

 $ agetty -V
 agetty from util-linux 2.31 (reload, issue, plymouth, debug)


> +#ifdef CRTSCTS
> +printf("%-30s: defined\n", "CRTSCTS");
> +#else
> +printf("%-30s: not in use\n", "CRTSCTS");
> +#endif

not sure if this is important

> +#ifdef DEBUGGING
> +printf("%-30s: defined\n", "DEBUGGING");
> +#else
> +printf("%-30s: not in use\n", "DEBUGGING");
> +#endif

ok

> +#ifdef HAVE_GETDOMAINNAME
> +printf("%-30s: defined\n", "HAVE_GETDOMAINNAME");
> +#else
> +printf("%-30s: not in use\n", "HAVE_GETDOMAINNAME");
> +#endif
> +
> +#ifdef HAVE_LIBUTIL_H
> +printf("%-30s: defined\n", "HAVE_LIBUTIL_H");
> +#else
> +printf("%-30s: not in use\n", "HAVE_LIBUTIL_H");
> +#endif

unimportant

> +#ifdef HAVE_STRUCT_TERMIOS_C_LINE
> +printf("%-30s: defined\n", "HAVE_STRUCT_TERMIOS_C_LINE");
> +#else
> +printf("%-30s: not in use\n", "HAVE_STRUCT_TERMIOS_C_LINE");
> +#endif
> +
> +#ifdef HAVE_SYS_PARAM_H
> +printf("%-30s: defined\n", "HAVE_SYS_PARAM_H");
> +#else
> +printf("%-30s: not in use\n", "HAVE_SYS_PARAM_H");
> +#endif
> +
> +#ifdef HAVE_UTMP_H
> +printf("%-30s: defined\n", "HAVE_UTMP_H");
> +#else
> +printf("%-30s: not in use\n", "HAVE_UTMP_H");
> +#endif

really unimportant

> +#ifdef HAVE_WIDECHAR
> +printf("%-30s: defined\n", "HAVE_WIDECHAR");
> +#else
> +printf("%-30s: not in use\n", "HAVE_WIDECHAR");
> +#endif

ok

> +#ifdef ISSUE
> +printf("%-30s: defined\n", "ISSUE");
> +#else
> +printf("%-30s: not in use\n", "ISSUE");
> +#endif

ok

> +#ifdef IUCLC
> +printf("%-30s: defined\n", "IUCLC");
> +#else
> +printf("%-30s: not in use\n", "IUCLC");
> +#endif
>
> +#ifdef IUTF8
> +printf("%-30s: defined\n", "IUTF8");
> +#else
> +printf("%-30s: not in use\n", "IUTF8");
> +#endif

unimportant

> +#ifdef KDGKBLED
> +printf("%-30s: defined\n", "KDGKBLED");
> +#else
> +printf("%-30s: not in use\n", "KDGKBLED");
> +#endif
> +
> +#ifdef KDGKBMODE
> +printf("%-30s: defined\n", "KDGKBMODE");
> +#else
> +printf("%-30s: not in use\n", "KDGKBMODE");
> +#endif

ok

> +#ifdef K_RAW
> +printf("%-30s: defined\n", "K_RAW");
> +#else
> +printf("%-30s: not in use\n", "K_RAW");
> +#endif
> +
> +#ifdef LOGIN_PROCESS
> +printf("%-30s: defined\n", "LOGIN_PROCESS");
> +#else
> +printf("%-30s: not in use\n", "LOGIN_PROCESS");
> +#endif
> +
> +#ifdef OLCUC
> +printf("%-30s: defined\n", "OLCUC");
> +#else
> +printf("%-30s: not in use\n", "OLCUC");
> +#endif
> +
> +#ifdef SYSV_STYLE
> +printf("%-30s: defined\n", "SYSV_STYLE");
> +#else
> +printf("%-30s: not in use\n", "SYSV_STYLE");
> +#endif

unimportant

> +#ifdef USE_PLYMOUTH_SUPPORT
> +printf("%-30s: defined\n", "USE_PLYMOUTH_SUPPORT");
> +#else
> +printf("%-30s: not in use\n", "USE_PLYMOUTH_SUPPORT");
> +#endif

ok

> +#ifdef USE_SYSLOG
> +printf("%-30s: defined\n", "USE_SYSLOG");
> +#else
> +printf("%-30s: not in use\n", "USE_SYSLOG");
> +#endif

ok

> +#ifdef XCASE
> +printf("%-30s: defined\n", "XCASE");
> +#else
> +printf("%-30s: not in use\n", "XCASE");
> +#endif
> +
> +#ifdef __FreeBSD_kernel__
> +printf("%-30s: defined\n", "__FreeBSD_kernel__");
> +#else
> +printf("%-30s: not in use\n", "__FreeBSD_kernel__");
> +#endif
> +
> +#ifdef __linux__
> +printf("%-30s: defined\n", "__linux__");
> +#else
> +printf("%-30s: not in use\n", "__linux__");
> +#endif

unimportant

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 9/9] agetty: fix invalid usage crash
  2017-07-31 19:55 ` [PATCH 9/9] agetty: fix invalid usage crash Sami Kerola
@ 2017-08-01  9:42   ` Karel Zak
  2017-08-05 16:34     ` Sami Kerola
  0 siblings, 1 reply; 17+ messages in thread
From: Karel Zak @ 2017-08-01  9:42 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jul 31, 2017 at 08:55:08PM +0100, Sami Kerola wrote:
> $ agetty
> agetty: not enough arguments: Success
> Segmentation fault (core dumped)
> 
> Reference: 9325dbfd2018b2a3b510617f4aa13777fbbe23c3
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  term-utils/agetty.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/term-utils/agetty.c b/term-utils/agetty.c
> index f06b9fc6e..d9e9548fa 100644
> --- a/term-utils/agetty.c
> +++ b/term-utils/agetty.c
> @@ -803,7 +803,8 @@ static void parse_args(int argc, char **argv, struct options *op)
>  
>  	if (argc < optind + 1) {
>  		log_warn(_("not enough arguments"));
> -		warn(_("not enough arguments"));
> +		warnx(_("not enough arguments"));
> +		errtryhelp(EXIT_FAILURE);
>  	}
>  
>  	/* Accept "tty", "baudrate tty", and "tty baudrate". */
> @@ -812,7 +813,8 @@ static void parse_args(int argc, char **argv, struct options *op)
>  		parse_speeds(op, argv[optind++]);
>  		if (argc < optind + 1) {
>  			log_warn(_("not enough arguments"));
> -			warn(_("not enough arguments"));
> +			warnx(_("not enough arguments"));
> +			exit(EXIT_FAILURE);

what about:

            errx(EXIT_FAILURE, _("not enough arguments"));

   Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h
  2017-08-01  9:27   ` Karel Zak
@ 2017-08-05 16:33     ` Sami Kerola
  0 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-08-05 16:33 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Tue, 1 Aug 2017, Karel Zak wrote:
> Frankly, I'm not sure if this patch improves readability of the code.
> Now we have to ways (pam and libuser) and both is pretty separated by
> .c and .h files. Not sure if merge it makes it better.

Fair enough. This change is dropped from my 2017wk30 branch.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 9/9] agetty: fix invalid usage crash
  2017-08-01  9:42   ` Karel Zak
@ 2017-08-05 16:34     ` Sami Kerola
  0 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-08-05 16:34 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Tue, 1 Aug 2017, Karel Zak wrote:

> On Mon, Jul 31, 2017 at 08:55:08PM +0100, Sami Kerola wrote:
> > @@ -812,7 +813,8 @@ static void parse_args(int argc, char **argv, struct options *op)
> >  		parse_speeds(op, argv[optind++]);
> >  		if (argc < optind + 1) {
> >  			log_warn(_("not enough arguments"));
> > -			warn(_("not enough arguments"));
> > +			warnx(_("not enough arguments"));
> > +			exit(EXIT_FAILURE);
> 
> what about:
> 
>             errx(EXIT_FAILURE, _("not enough arguments"));

That is better. Updates in my 2017wk30 branch.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 8/9] agetty: add --compile-time option
  2017-08-01  9:41   ` Karel Zak
@ 2017-08-05 16:44     ` Sami Kerola
  0 siblings, 0 replies; 17+ messages in thread
From: Sami Kerola @ 2017-08-05 16:44 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Tue, 1 Aug 2017, Karel Zak wrote:

> On Mon, Jul 31, 2017 at 08:55:07PM +0100, Sami Kerola wrote:
> > This command has the most compile time #ifdef code.  It is time to add an
> > option to print what was defined when the command was compiled, so that
> > debugging is easier.
> > 
> > Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> > ---
> >  term-utils/agetty.8 |   3 +
> >  term-utils/agetty.c | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 254 insertions(+)
> > 
> > diff --git a/term-utils/agetty.8 b/term-utils/agetty.8
> > index 23adff3b1..230c47cd5 100644
> > --- a/term-utils/agetty.8
> > +++ b/term-utils/agetty.8
> > @@ -281,6 +281,9 @@ if the user has not yet commenced logging in.  After doing so the command will
> >  exit.  This feature might be unsupported on systems without Linux
> >  .BR inotify (7).
> >  .TP
> > +\-\-compile\-time
> > +Display compile time definitions.
> 
> I don't like the option name ;-)

It felt a bit sticky when proposing, but I'm clad that sent it anyway as 
you point out a lot better way.

> > +static void __attribute__((__noreturn__)) compile_time(void)
> > +{
> > +#ifdef B19200
> > +printf("%-30s: defined\n", "B19200");
> > +#else
> > +printf("%-30s: not in use\n", "B19200");
> > +#endif
> 
> This is overkill. I can imagine --list-speeds to list built-in speeds
> in format "<speed>\n"
> 
> static cost char *speeds[] = {
> #ifdef B19200
>     "B19200",
> #endif
> };
> 
> ... and so on.

There is already speedlist, so how about reusing it. Here is a commit that 
adds the proposed option that way.

https://github.com/kerolasa/lelux-utiliteetit/commit/11841430c9b94d4f0246005a826a1c17a5af972d

> > +#ifdef AGETTY_RELOAD
> > +printf("%-30s: defined\n", "AGETTY_RELOAD");
> > +#else
> > +printf("%-30s: not in use\n", "AGETTY_RELOAD");
> > +#endif
> 
> For this purpose we can use --version, see for example mount:
> 
>  $ mount -V
>  mount from util-linux 2.28.2 (libmount 2.28.2: selinux, btrfs, force-mountinfo, assert, debug)
> 
> the same we can use for agetty to list *really important* enabled
> features, for example:
> 
>  $ agetty -V
>  agetty from util-linux 2.31 (reload, issue, plymouth, debug)

Oh yes, that is a lot nicer way. See below for the new version of the 
output. Primary reason I introduced output_version() is to avoid having 
the features[] array in scope when it is not needed.

https://github.com/kerolasa/lelux-utiliteetit/commit/63d94613a887c9a5f741d87bff4c7979293c4baf



> > +#ifdef CRTSCTS
> > +printf("%-30s: defined\n", "CRTSCTS");
> > +#else
> > +printf("%-30s: not in use\n", "CRTSCTS");
> > +#endif
> 
> not sure if this is important
> 
> > +#ifdef DEBUGGING
> > +printf("%-30s: defined\n", "DEBUGGING");
> > +#else
> > +printf("%-30s: not in use\n", "DEBUGGING");
> > +#endif
> 
> ok
> 
> > +#ifdef HAVE_GETDOMAINNAME
> > +printf("%-30s: defined\n", "HAVE_GETDOMAINNAME");
> > +#else
> > +printf("%-30s: not in use\n", "HAVE_GETDOMAINNAME");
> > +#endif
> > +
> > +#ifdef HAVE_LIBUTIL_H
> > +printf("%-30s: defined\n", "HAVE_LIBUTIL_H");
> > +#else
> > +printf("%-30s: not in use\n", "HAVE_LIBUTIL_H");
> > +#endif
> 
> unimportant
> 
> > +#ifdef HAVE_STRUCT_TERMIOS_C_LINE
> > +printf("%-30s: defined\n", "HAVE_STRUCT_TERMIOS_C_LINE");
> > +#else
> > +printf("%-30s: not in use\n", "HAVE_STRUCT_TERMIOS_C_LINE");
> > +#endif
> > +
> > +#ifdef HAVE_SYS_PARAM_H
> > +printf("%-30s: defined\n", "HAVE_SYS_PARAM_H");
> > +#else
> > +printf("%-30s: not in use\n", "HAVE_SYS_PARAM_H");
> > +#endif
> > +
> > +#ifdef HAVE_UTMP_H
> > +printf("%-30s: defined\n", "HAVE_UTMP_H");
> > +#else
> > +printf("%-30s: not in use\n", "HAVE_UTMP_H");
> > +#endif
> 
> really unimportant
> 
> > +#ifdef HAVE_WIDECHAR
> > +printf("%-30s: defined\n", "HAVE_WIDECHAR");
> > +#else
> > +printf("%-30s: not in use\n", "HAVE_WIDECHAR");
> > +#endif
> 
> ok
> 
> > +#ifdef ISSUE
> > +printf("%-30s: defined\n", "ISSUE");
> > +#else
> > +printf("%-30s: not in use\n", "ISSUE");
> > +#endif
> 
> ok
> 
> > +#ifdef IUCLC
> > +printf("%-30s: defined\n", "IUCLC");
> > +#else
> > +printf("%-30s: not in use\n", "IUCLC");
> > +#endif
> >
> > +#ifdef IUTF8
> > +printf("%-30s: defined\n", "IUTF8");
> > +#else
> > +printf("%-30s: not in use\n", "IUTF8");
> > +#endif
> 
> unimportant
> 
> > +#ifdef KDGKBLED
> > +printf("%-30s: defined\n", "KDGKBLED");
> > +#else
> > +printf("%-30s: not in use\n", "KDGKBLED");
> > +#endif
> > +
> > +#ifdef KDGKBMODE
> > +printf("%-30s: defined\n", "KDGKBMODE");
> > +#else
> > +printf("%-30s: not in use\n", "KDGKBMODE");
> > +#endif
> 
> ok
> 
> > +#ifdef K_RAW
> > +printf("%-30s: defined\n", "K_RAW");
> > +#else
> > +printf("%-30s: not in use\n", "K_RAW");
> > +#endif
> > +
> > +#ifdef LOGIN_PROCESS
> > +printf("%-30s: defined\n", "LOGIN_PROCESS");
> > +#else
> > +printf("%-30s: not in use\n", "LOGIN_PROCESS");
> > +#endif
> > +
> > +#ifdef OLCUC
> > +printf("%-30s: defined\n", "OLCUC");
> > +#else
> > +printf("%-30s: not in use\n", "OLCUC");
> > +#endif
> > +
> > +#ifdef SYSV_STYLE
> > +printf("%-30s: defined\n", "SYSV_STYLE");
> > +#else
> > +printf("%-30s: not in use\n", "SYSV_STYLE");
> > +#endif
> 
> unimportant
> 
> > +#ifdef USE_PLYMOUTH_SUPPORT
> > +printf("%-30s: defined\n", "USE_PLYMOUTH_SUPPORT");
> > +#else
> > +printf("%-30s: not in use\n", "USE_PLYMOUTH_SUPPORT");
> > +#endif
> 
> ok
> 
> > +#ifdef USE_SYSLOG
> > +printf("%-30s: defined\n", "USE_SYSLOG");
> > +#else
> > +printf("%-30s: not in use\n", "USE_SYSLOG");
> > +#endif
> 
> ok
> 
> > +#ifdef XCASE
> > +printf("%-30s: defined\n", "XCASE");
> > +#else
> > +printf("%-30s: not in use\n", "XCASE");
> > +#endif
> > +
> > +#ifdef __FreeBSD_kernel__
> > +printf("%-30s: defined\n", "__FreeBSD_kernel__");
> > +#else
> > +printf("%-30s: not in use\n", "__FreeBSD_kernel__");
> > +#endif
> > +
> > +#ifdef __linux__
> > +printf("%-30s: defined\n", "__linux__");
> > +#else
> > +printf("%-30s: not in use\n", "__linux__");
> > +#endif
> 
> unimportant
> 
>     Karel

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/9] pull: various removals and few fixes
  2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
                   ` (8 preceding siblings ...)
  2017-07-31 19:55 ` [PATCH 9/9] agetty: fix invalid usage crash Sami Kerola
@ 2017-08-07  7:54 ` Karel Zak
  9 siblings, 0 replies; 17+ messages in thread
From: Karel Zak @ 2017-08-07  7:54 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Jul 31, 2017 at 08:54:59PM +0100, Sami Kerola wrote:
>   git://github.com/kerolasa/lelux-utiliteetit.git 2017wk30

Merged, thanks!

    Karel
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-08-07  7:54 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 19:54 [PATCH 0/9] pull: various removals and few fixes Sami Kerola
2017-07-31 19:55 ` [PATCH 1/9] chfn, chsh: merge auth.h, islocal.h and libuser.h to ch-common.h Sami Kerola
2017-08-01  9:27   ` Karel Zak
2017-08-05 16:33     ` Sami Kerola
2017-07-31 19:55 ` [PATCH 2/9] include: move pamfail.h to auth.c Sami Kerola
2017-07-31 19:55 ` [PATCH 3/9] vipw: use explicit_bzero() to clear buffer after copy Sami Kerola
2017-07-31 19:55 ` [PATCH 4/9] uuidparse: nil uuid have all bits set to zero Sami Kerola
2017-07-31 19:55 ` [PATCH 5/9] libuuid: use access(2) when checking /dev/random availability Sami Kerola
2017-07-31 19:55 ` [PATCH 6/9] bash-completion: look for look completions Sami Kerola
2017-07-31 19:55 ` [PATCH 7/9] agetty: remove dead DO_DEVFS_FIDDLING code segment Sami Kerola
2017-07-31 19:55 ` [PATCH 8/9] agetty: add --compile-time option Sami Kerola
2017-08-01  9:41   ` Karel Zak
2017-08-05 16:44     ` Sami Kerola
2017-07-31 19:55 ` [PATCH 9/9] agetty: fix invalid usage crash Sami Kerola
2017-08-01  9:42   ` Karel Zak
2017-08-05 16:34     ` Sami Kerola
2017-08-07  7:54 ` [PATCH 0/9] pull: various removals and few fixes Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.