various changes, uuid tests, ctrlaltdel improvements and so on
Hi Karel,
You mentioned something about uuid tests, so I wrote couple. They do not test any randomness aspects of the commands, but general execution and request flow, so not 100% perfect but much better than no tests at all.
The ctrlaltdel(8) has a new feature in these changes - when ran without arguments it will display what is the CAD function. Basically this is the same thinking pattern that we applied earlier to swapon(8).
The rest of the pull is minor updateds touching last(1), and nologin(1).
----------------------------------------------------------------
The following changes since commit d5b7d2912afceac3774d1aaea9e8486b54d4e9e9:
libblkid: make XFS Log visible for wipefs (2015-10-13 12:02:17 +0200)
are available in the git repository at:
git://github.com/kerolasa/lelux-utiliteetit.git various
for you to fetch changes up to 150029cf0057a5f1278a2abb40753c321126be74:
ctrlaltdel: display setting when ran without arguments (2015-10-13 12:17:07 +0100)
----------------------------------------------------------------
Sami Kerola (8):
last: display input file in usage() according to command name
nologin: require /etc/nologin.txt to be file
libuuid: add uuid_generate_file() function
tests: add uuidgen check
tests: add uuidd check
ctrlaltdel: improve error messaging
docs: update ctrlaltdel.8 man page
ctrlaltdel: display setting when ran without arguments
include/pathnames.h | 3 ++ libuuid/man/uuid_generate.3 | 11 +++++++ libuuid/src/gen_uuid.c | 21 +++++++++++++ libuuid/src/libuuid.sym | 8 +++++ libuuid/src/uuid.h | 2 ++ login-utils/last.c | 17 +++++----- login-utils/nologin.c | 5 ++- misc-utils/Makemodule.am | 10 ++++++ misc-utils/uuidd.c | 16 ++++++++++ misc-utils/uuidgen.c | 24 ++++++++++++++ sys-utils/ctrlaltdel.8 | 26 +++++++++------ sys-utils/ctrlaltdel.c | 75 ++++++++++++++++++++++++++++++++++---------- tests/commands.sh | 2 ++ tests/expected/uuid/uuidd | 7 +++++ tests/expected/uuid/uuidgen | 6 ++++ tests/ts/uuid/0x00000000 | Bin 0 -> 16 bytes tests/ts/uuid/0xdeadbeef | 1 + tests/ts/uuid/0xffffffff | 1 + tests/ts/uuid/uuidd | 33 +++++++++++++++++++ tests/ts/uuid/uuidgen | 30 ++++++++++++++++++ 20 files changed, 261 insertions(+), 37 deletions(-) create mode 100644 tests/expected/uuid/uuidd create mode 100644 tests/expected/uuid/uuidgen create mode 100644 tests/ts/uuid/0x00000000 create mode 100644 tests/ts/uuid/0xdeadbeef create mode 100644 tests/ts/uuid/0xffffffff create mode 100755 tests/ts/uuid/uuidd create mode 100755 tests/ts/uuid/uuidgen
Signature · 1 line
2.6.1
PATCH 1/8 last: display input file in usage() according to command name
Default depends on whether the executable is called 'lastb' or something else.
--- login-utils/last.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
login-utils/last.c +8 -9
@@ -543,7 +543,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t logout_ti } -static void __attribute__((__noreturn__))usage (FILE *out) +static void __attribute__((__noreturn__))usage (const struct last_control *ctl,FILE *out) {fputs (USAGE_HEADER , out); fprintf(out, _(
@@ -557,7 +557,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)fputs (_ (" -a, --hostlast display hostnames in the last column\n" ), out);fputs (_ (" -d, --dns translate the IP number back into a hostname\n" ), out);fprintf (out, -_ (" -f, --file <file> use a specific file instead of %s\n" ), _PATH_WTMP); +_ (" -f, --file <file> use a specific file instead of %s\n" ), ctl->lastb ? _PATH_BTMP : _PATH_WTMP);fputs (_ (" -F, --fulltimes print full login and logout times and dates\n" ), out);fputs (_ (" -i, --ip display IP numbers in numbers-and-dots notation\n" ), out);fputs (_ (" -n, --limit <number> how many lines to show\n" ), out);
@@ -911,7 +911,10 @@ int main(int argc, char **argv)bindtextdomain (PACKAGE ,LOCALEDIR );textdomain (PACKAGE );atexit (close_stdout); - +/* +* Which file do we want to read? +*/ + ctl.lastb =strcmp (program_invocation_short_name,"lastb" ) ==0 ?1 :0 ;while ((c =getopt_long (argc, argv,"hVf:n:RxadFit:p:s:0123456789w" , long_opts,NULL )) !=-1 ) {
@@ -919,7 +922,7 @@ int main(int argc, char **argv)switch (c) {case 'h' : -usage (stdout); +usage (&ctl, stdout);break ;case 'V' :printf (UTIL_LINUX_VERSION );
@@ -979,7 +982,7 @@ int main(int argc, char **argv) ctl.time_fmt =which_time_format (optarg);break ;default : -usage (stderr); +usage (&ctl, stderr);break ; } }
@@ -987,10 +990,6 @@ int main(int argc, char **argv)if (optind < argc) ctl.show = argv + optind; -/* -* Which file do we want to read? -*/ - ctl.lastb =strcmp (program_invocation_short_name,"lastb" ) ==0 ?1 :0 ;if (!files) { files =xmalloc (sizeof (char *)); files[nfiles++] =xstrdup (ctl.lastb ? _PATH_BTMP : _PATH_WTMP);
Signature · 1 line
2.6.1
PATCH 2/8 nologin: require /etc/nologin.txt to be file
In reply to Sami KerolaThis makes silly practical jokes impossible, like for example symlinking /dev/null or dev/random to /etc/nologin.txt
--- login-utils/nologin.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
login-utils/nologin.c +4 -1
@@ -3,6 +3,7 @@*/ #include <stdio.h> +#include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <string.h>
@@ -38,6 +39,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)int main (int argc,char *argv[]) {int c, fd; +struct stat st;static const struct option longopts[] = { {"help" ,0 ,0 ,'h' }, {"version" ,0 ,0 ,'V' },
@@ -63,7 +65,8 @@ int main(int argc, char *argv[]) } fd =open (_PATH_NOLOGIN_TXT,O_RDONLY ); -if (fd >=0 ) { + c =fstat (fd, &st); +if (fd >=0 && !c &&S_ISREG (st.st_mode)) {char buf[BUFSIZ ];ssize_t rd;
Signature · 1 line
2.6.1
PATCH 3/8 libuuid: add uuid_generate_file() function
In reply to Sami KerolaThe uuid_generate_file() allows generating UUID using input file, and thus leading to stable output. Purpose of this function is to have a facility that allows tests to be wrote.
--- libuuid/man/uuid_generate.3 | 11 +++++++++++ libuuid/src/gen_uuid.c | 21 +++++++++++++++++++++ libuuid/src/libuuid.sym | 8 ++++++++ libuuid/src/uuid.h | 2 ++ 4 files changed, 42 insertions(+)
libuuid/man/uuid_generate.3 +11 -0
@@ -41,6 +41,7 @@ uuid_generate_time_safe \- create a new unique UUID value .BI "void uuid_generate_random(uuid_t " out ); .BI "void uuid_generate_time(uuid_t " out ); .BI "int uuid_generate_time_safe(uuid_t " out ); +.BI "int uuid_generate_file(uuid_t " out ", const char " *path ");" .fi .SH DESCRIPTION The
@@ -100,11 +101,21 @@ the universe according to Carl Sagan's The new UUID can reasonably be considered unique among all UUIDs created on the local system, and among UUIDs created on other systems in the past and in the future. +.sp +The +.B uuid_generate_file +function will read up to 16 bytes from beginning of a file as a not-random +source of UUID. Purpose of this function is to provide a facility that will +always return the same UUID, and thus is ideal for testing. .SH RETURN VALUE The newly created UUID is returned in the memory location pointed to by .IR out . .B uuid_generate_time_safe returns zero if the UUID has been generated in a safe manner, \-1 otherwise. +The +.B uuid_generate_file +will return zero for success, or 1 when errno indicates an error with file +defined by path. .SH "CONFORMING TO" OSF DCE 1.1 .SH AUTHOR
libuuid/src/gen_uuid.c +21 -0
@@ -551,3 +551,24 @@ void uuid_generate(uuid_t out)else uuid_generate_time (out); } + +/* +* Generate file-based UUID and store it to @out. Useful for testing. +* +*/ +int uuid_generate_file (uuid_t out,const char *path) +{ +int fd; +uuid_t buf = {0 }; +struct uuid uu = {0 }; + + fd =open (path,O_RDONLY ); +if (fd <0 ) +return 1 ; +if ((read (fd, &buf,sizeof (buf))) <0 ) +return 1 ; +close (fd); +uuid_unpack (buf, &uu); +uuid_pack (&uu, out); +return 0 ; +}
libuuid/src/libuuid.sym +8 -0
@@ -34,6 +34,14 @@ global: uuid_generate_time_safe; } UUID_1.0; +/* + * version(s) since util-linux 2.28 + */ +UUID_2.28 { +global: + uuid_generate_file; +} UUID_2.20; + /* * __uuid_* this is not part of the official API, this is
libuuid/src/uuid.h +2 -0
@@ -52,6 +52,7 @@ typedef unsigned char uuid_t[16];/* UUID Type definitions */ #define UUID_TYPE_DCE_TIME 1#define UUID_TYPE_DCE_RANDOM 4 +#define UUID_TYPE_DCE_FILE 8/* Allow UUID constants to be defined */ #ifdef __GNUC__
@@ -80,6 +81,7 @@ extern void uuid_generate(uuid_t out);extern void uuid_generate_random (uuid_t out);extern void uuid_generate_time (uuid_t out);extern int uuid_generate_time_safe (uuid_t out); +extern int uuid_generate_file (uuid_t out,const char *path);/* isnull.c */ extern int uuid_is_null (const uuid_t uu);
Signature · 1 line
2.6.1
PATCH 4/8 tests: add uuidgen check
In reply to Sami KerolaThis check will try functionality of uuidgen, leaving out the validation uuid's are truly unique.
--- misc-utils/Makemodule.am | 5 +++++ misc-utils/uuidgen.c | 24 ++++++++++++++++++++++++ tests/commands.sh | 1 + tests/expected/uuid/uuidgen | 6 ++++++ tests/ts/uuid/0x00000000 | Bin 0 -> 16 bytes tests/ts/uuid/0xdeadbeef | 1 + tests/ts/uuid/0xffffffff | 1 + tests/ts/uuid/uuidgen | 30 ++++++++++++++++++++++++++++++ 8 files changed, 68 insertions(+) create mode 100644 tests/expected/uuid/uuidgen create mode 100644 tests/ts/uuid/0x00000000 create mode 100644 tests/ts/uuid/0xdeadbeef create mode 100644 tests/ts/uuid/0xffffffff create mode 100755 tests/ts/uuid/uuidgen
misc-utils/Makemodule.am +5 -0
@@ -85,6 +85,11 @@ dist_man_MANS += misc-utils/uuidgen.1 uuidgen_SOURCES = misc-utils/uuidgen.c uuidgen_LDADD = $(LDADD) libuuid.la uuidgen_CFLAGS = $(AM_CFLAGS) -I$(ul_libuuid_incdir) + +check_PROGRAMS += test_uuidgen +test_uuidgen_SOURCES = $(uuidgen_SOURCES) +test_uuidgen_LDADD = $(uuidgen_LDADD) +test_uuidgen_CFLAGS = -DTEST_UUIDGEN $(uuidgen_CFLAGS) endif if BUILD_UUIDD
misc-utils/uuidgen.c +24 -0
@@ -28,6 +28,9 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)fputs (_ ("Create a new UUID value.\n" ), out);fputs (USAGE_OPTIONS , out); +#ifdef TEST_UUIDGEN +fputs (" --file <file> generate <file> based uuid" , out); +#endif fputs(_(" -r, --random generate random-based uuid\n" " -t, --time generate time-based uuid\n" " -V, --version output version information and exit\n"
@@ -44,8 +47,17 @@ main (int argc, char *argv[])int do_type =0 ;char str[37 ];uuid_t uu; +#ifdef TEST_UUIDGEN +char *file; +enum { +OPT_FILE =CHAR_MAX +1 + }; +#endif static const struct option longopts[] = { +#ifdef TEST_UUIDGEN + {"file" , required_argument,NULL ,OPT_FILE }, +#endif {"random" , no_argument,NULL ,'r' }, {"time" , no_argument,NULL ,'t' }, {"version" , no_argument,NULL ,'V' },
@@ -60,6 +72,12 @@ main (int argc, char *argv[])while ((c =getopt_long (argc, argv,"rtVh" , longopts,NULL )) !=-1 )switch (c) { +#ifdef TEST_UUIDGEN +case OPT_FILE : + do_type =UUID_TYPE_DCE_FILE ; + file = optarg; +break ; +#endif case 't' : do_type =UUID_TYPE_DCE_TIME ;break ;
@@ -76,6 +94,12 @@ main (int argc, char *argv[]) }switch (do_type) { +#ifdef TEST_UUIDGEN +case UUID_TYPE_DCE_FILE : +if (uuid_generate_file (uu, file)) +err (EXIT_FAILURE ,"%s" , file); +break ; +#endif case UUID_TYPE_DCE_TIME :uuid_generate_time (uu);break ;
tests/commands.sh +1 -0
@@ -30,6 +30,7 @@ TS_HELPER_SCRIPT="$top_builddir/test_script" TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive" TS_HELPER_STRUTILS="$top_builddir/test_strutils" TS_HELPER_SYSINFO="$top_builddir/test_sysinfo" +TS_HELPER_UUIDGEN="$top_builddir/test_uuidgen" # paths to commands TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
tests/expected/uuid/uuidgen new file +6 -0
@@ -0,0 +1,6 @@ +00000000-0000-0000-0000-000000000000 +return value: 0 +deadface-cafe-babe-feed-baadbeeff00d +return value: 0 +ffffffff-ffff-ffff-ffff-ffffffffffff +return value: 0
tests/ts/uuid/0x00000000 new file binary +0 -0
tests/ts/uuid/0xdeadbeef new file +1 -0
@@ -0,0 +1 @@ +ޭ�������������
*��*
\ No newline at end of file
tests/ts/uuid/0xffffffff new file +1 -0
@@ -0,0 +1 @@ +����������������
tests/ts/uuid/uuidgen new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="uuidgen" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_UUIDGEN" + +$TS_HELPER_UUIDGEN --file $TS_SELF/0x00000000 > $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT +$TS_HELPER_UUIDGEN --file $TS_SELF/0xdeadbeef >> $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT +$TS_HELPER_UUIDGEN --file $TS_SELF/0xffffffff >> $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT + +ts_finalize
Signature · 1 line
2.6.1
PATCH 5/8 tests: add uuidd check
In reply to Sami KerolaThis check will try functionality of uuidd, leaving out the validation uuid's are truly unique.
--- misc-utils/Makemodule.am | 5 +++++ misc-utils/uuidd.c | 16 ++++++++++++++++ tests/commands.sh | 1 + tests/expected/uuid/uuidd | 7 +++++++ tests/ts/uuid/uuidd | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 tests/expected/uuid/uuidd create mode 100755 tests/ts/uuid/uuidd
misc-utils/Makemodule.am +5 -0
@@ -106,6 +106,11 @@ systemdsystemunit_DATA += \ misc-utils/uuidd.service \ misc-utils/uuidd.socket endif + +check_PROGRAMS += test_uuidd2 +test_uuidd2_SOURCES = $(uuidd_SOURCES) +test_uuidd2_LDADD = $(uuidd_LDADD) +test_uuidd2_CFLAGS = -DTEST_UUIDD $(uuidd_CFLAGS) endif # BUILD_UUIDD PATHFILES += \
misc-utils/uuidd.c +16 -0
@@ -331,6 +331,12 @@ static void server_loop(const char *socket_path, const char *pidfile_path,POLLFD_SIGNAL =0 , POLLFD_SOCKET }; +#ifdef TEST_UUIDD +const char *test_file =getenv ("UUIDD_RANDOM_SOURCE" ); + +if (!test_file) +errx (EXIT_FAILURE ,"UUIDD_RANDOM_SOURCE: not set" ); +#endif #ifdef HAVE_LIBSYSTEMD if (!uuidd_cxt->no_sock)/* no_sock implies no_fork and no_pid */
@@ -468,7 +474,12 @@ static void server_loop(const char *socket_path, const char *pidfile_path,break ;case UUIDD_OP_TIME_UUID : num =1 ; +#ifdef TEST_UUIDD +if (uuid_generate_file (uu, test_file)) +err (EXIT_FAILURE ,"%s" , test_file); +#else __uuid_generate_time (uu, &num); +#endif if (uuidd_cxt->debug) {uuid_unparse (uu, str);fprintf (stderr,_ ("Generated time UUID: %s\n" ), str);
@@ -478,7 +489,12 @@ static void server_loop(const char *socket_path, const char *pidfile_path,break ;case UUIDD_OP_RANDOM_UUID : num =1 ; +#ifdef TEST_UUIDD +if (uuid_generate_file (uu, test_file)) +err (EXIT_FAILURE ,"%s" , test_file); +#else __uuid_generate_random (uu, &num); +#endif if (uuidd_cxt->debug) {uuid_unparse (uu, str);fprintf (stderr,_ ("Generated random UUID: %s\n" ), str);
tests/commands.sh +1 -0
@@ -30,6 +30,7 @@ TS_HELPER_SCRIPT="$top_builddir/test_script" TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive" TS_HELPER_STRUTILS="$top_builddir/test_strutils" TS_HELPER_SYSINFO="$top_builddir/test_sysinfo" +TS_HELPER_UUIDD2="$top_builddir/test_uuidd2" TS_HELPER_UUIDGEN="$top_builddir/test_uuidgen" # paths to commands
tests/expected/uuid/uuidd new file +7 -0
@@ -0,0 +1,7 @@ +return value: 0 +deadface-cafe-babe-feed-baadbeeff00d +return value: 0 +deadface-cafe-babe-feed-baadbeeff00d +return value: 0 +Killed uuidd running at pid <num>. +return value: 0
tests/ts/uuid/uuidd new file +33 -0
@@ -0,0 +1,33 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="uuidd" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_HELPER_UUIDD2" + +UUIDD_RANDOM_SOURCE=$TS_SELF/0xdeadbeef $TS_HELPER_UUIDD2 --pid $TS_OUTDIR/pid --socket $TS_OUTDIR/socket > $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT +$TS_HELPER_UUIDD2 --debug --random --socket $TS_OUTDIR/socket >> $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT +$TS_HELPER_UUIDD2 --debug --time --socket $TS_OUTDIR/socket >> $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT +$TS_HELPER_UUIDD2 --debug --kill --socket $TS_OUTDIR/socket | + sed 's/pid [0-9]*.$/pid <num>./' >> $TS_OUTPUT 2>&1 +echo "return value: $?" >> $TS_OUTPUT + +ts_finalize
Signature · 1 line
2.6.1
PATCH 6/8 ctrlaltdel: improve error messaging
In reply to Sami KerolaTell user what is wrong rather than print usage().
--- sys-utils/ctrlaltdel.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
sys-utils/ctrlaltdel.c +12 -11
@@ -21,7 +21,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)fprintf (out,_ (" %s hard|soft\n" ), program_invocation_short_name);fprintf (out,USAGE_SEPARATOR ); -fprintf (out,"Set the function of the Ctrl-Alt-Del combination.\n" ); +fprintf (out,_ ("Set the function of the Ctrl-Alt-Del combination.\n" ));fprintf (out,USAGE_OPTIONS );fprintf (out,USAGE_HELP );
@@ -33,6 +33,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)int main (int argc,char **argv) {int ch; +unsigned int cmd;static const struct option longopts[] = { {"version" , no_argument,NULL ,'V' }, {"help" , no_argument,NULL ,'h' },
@@ -59,15 +60,15 @@ int main(int argc, char **argv)errx (EXIT_FAILURE ,_ ("You must be root to set the Ctrl-Alt-Del behavior" )); -if (argc ==2 && !strcmp ("hard" , argv[1 ])) { -if (my_reboot (LINUX_REBOOT_CMD_CAD_ON ) <0 ) -err (EXIT_FAILURE ,"reboot" ); - }else if (argc ==2 && !strcmp ("soft" , argv[1 ])) { -if (my_reboot (LINUX_REBOOT_CMD_CAD_OFF ) <0 ) -err (EXIT_FAILURE ,"reboot" ); - }else { -usage (stderr); - } - +if (argc <2 ) +errx (EXIT_FAILURE ,_ ("not enough arguments" )); +if (!strcmp ("hard" , argv[1 ])) + cmd =LINUX_REBOOT_CMD_CAD_ON ; +else if (!strcmp ("soft" , argv[1 ])) + cmd =LINUX_REBOOT_CMD_CAD_OFF ; +else +errx (EXIT_FAILURE ,_ ("unknown argument: %s" ), argv[1 ]); +if (my_reboot (cmd) <0 ) +err (EXIT_FAILURE ,"reboot" );return EXIT_SUCCESS ; }
Signature · 1 line
2.6.1
PATCH 7/8 docs: update ctrlaltdel.8 man page
In reply to Sami KerolaMost significant clarification is to tell hard C_A_D is the default in linux kernel. Update also kernel reference, and improve readability.
Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/reboot.c
--- sys-utils/ctrlaltdel.8 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
sys-utils/ctrlaltdel.8 +12 -9
@@ -1,21 +1,23 @@ .\" Copyright 1992, 1993 Rickard E. Faith ([email protected]) .\" May be distributed under the GNU General Public License -.TH CTRLALTDEL 8 "August 2011" "util-linux" "System Administration" +.TH CTRLALTDEL 8 "October 2015" "util-linux" "System Administration" .SH NAME ctrlaltdel \- set the function of the Ctrl-Alt-Del combination .SH SYNOPSIS .BR "ctrlaltdel hard" | soft .SH DESCRIPTION Based on examination of the -.I linux/kernel/sys.c +.I linux/kernel/reboot.c code, it is clear that there are two supported functions that the -Ctrl-Alt-Del sequence can perform: a -.I hard -reset, which immediately reboots the computer without calling +Ctrl-Alt-Del sequence can perform. +.TP +.B hard +Immediately reboot the computer without calling .BR sync (2) -and without any other preparation; and a -.I soft -reset, which sends the SIGINT (interrupt) signal to the +and without any other preparation. This is the default. +.TP +.B soft +Will make kernel to send the SIGINT (interrupt) signal to the .B init process (this is always the process with PID 1). If this option is used, the
@@ -39,7 +41,8 @@ Display help text and exit. .SH FILES .I /etc/rc.local .SH "SEE ALSO" -.BR init (8) +.BR init (8), +.BR systemd (1) .SH AUTHOR .UR [email protected] Peter Orbaek
Signature · 1 line
2.6.1
PATCH 8/8 ctrlaltdel: display setting when ran without arguments
In reply to Sami KerolaThis is more useful than printing an error.
--- include/pathnames.h | 3 +++ sys-utils/ctrlaltdel.8 | 5 +++- sys-utils/ctrlaltdel.c | 70 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 62 insertions(+), 16 deletions(-)
include/pathnames.h +3 -0
@@ -208,5 +208,8 @@/* logger paths */ #define _PATH_DEVLOG "/dev/log" +/* ctrlaltdel paths */ +#define _PATH_PROC_CTRL_ALT_DEL "/proc/sys/kernel/ctrl-alt-del" +#endif /* PATHNAMES_H */
sys-utils/ctrlaltdel.8 +4 -1
@@ -27,8 +27,11 @@ program must support this feature. Since there are now several programs in the Linux community, please consult the documentation for the version that you are currently using. .PP +When command is ran without arguments it will display current function in +use. +.PP .B ctrlaltdel -is usually used in the +function is usually set in the .I /etc/rc.local file. .SH OPTIONS
sys-utils/ctrlaltdel.c +55 -15
90 lines not on this page · raw message
Signature · 1 line
2.6.1
Karel Zak
maintainerRe: [PATCH 3/8] libuuid: add uuid_generate_file() function
In reply to Sami KerolaQuoted 3 lines · Sami Kerola
The
uuid_generate_file()allows generating UUID using input file, and thus leading to stable output. Purpose of this function is to have a facility that allows tests to be wrote.
Well, if you want to generate non-random stuff then it seems enough to modify __uuid_generate_random() and __uuid_generate_time() to return non-random stuff on -DLIBUUID_ENABLE_TEST.
The problem is that things like get_clock(), pack, unpack, parse and unparse functions will be still untested.
What about to support random UUIDs in our tests and modify the __uuid_generate functions to copy unpacked raw result to any file? Something like:
int __uuid_generate_time(uuid_t out, int *num)
{
... generate struct uu as usually ...
#ifdef LIBUUID_ENABLE_TEST
ts_path = genenv("LIBUUID_TEST_PATH");
if (ts_path)
write_raw_uuid(uu, ts_path);#endif
return ret;
}
where write_uraw_uuid() is function to write struct uuid to the <ts_path>/<pid>.
Then we can write
test_uuid --random|--time <file>
this program
1/ ask libuuid for a new UUID
2/ unparse and unpack to get struct uuid
3/ write struct uuid to the <file> by write_uraw_uuid()
and in the shell script we can by diff -u compare $LIBUUID_TEST_PATH/<pid> with <file>.
The <pid> is also possible to use to check if UUID has been really generated by uuidd. (It would be nice to have two sub-tests, one with uuidd and one without uuid.)
Note that uuid_unpack() is not exported by library API, so you have to link libuuid/src/unpack.c directly to the test_uuid.c.
(It would be also possible to analyze struct uuid from $LIBUUID_TEST_PATH to make sure that for example get_node_id() works as expected, etc... but this is not urgent.)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com