summaryrefslogtreecommitdiff
path: root/src/userdb/userdbctl.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: reset optind to 0 when GNU extensions in optstring are usedYu Watanabe2023-03-291-0/+4
| | | | | | | | | | Otherwise, if getopt() and friends are used before parse_argv(), then the GNU extensions may be ignored. This should not change any behavior at least now, as we usually use getopt_long() only once per invocation. But in the next commit, getopt_long() will be used for other arrays, hence this change will become necessary.
* userdbctl: flush stdout before running the chain commandFrantisek Sumsal2023-03-241-0/+1
| | | | | | | | | | | Otherwise it's quite difficult to capture the entire output: $ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA//dxI2xLg4MgxIKKZv1nqwTEIlE/fdakii2Fb75pG+ foo@bar.tld ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMlaqG2rTMje5CQnfjXJKmoSpEVJ2gWtx4jBvsQbmee2XbU/Qdq5+SRisssR9zVuxgg5NA5fv08MgjwJQMm+csc= hello@world.tld hello $ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello | tee hello
* userdbctl: don't show legend when dumping JSON with servicesFrantisek Sumsal2023-03-241-1/+1
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* tree-wide: replace "plural(s)" by "plurals"Zbigniew Jędrzejewski-Szmek2022-10-171-2/+2
| | | | | | | | (s) is just ugly with a vibe of DOS. In most cases just using the normal plural form is more natural and gramatically correct. There are some log_debug() statements left, and texts in foreign licenses or headers. Those are not touched on purpose.
* shared/format-table: use enum instead of Table.empty_stringZbigniew Jędrzejewski-Szmek2022-09-221-2/+2
| | | | | | | | | | | | All users were setting this to some static string (usually "-"), so let's simplify things by not doing strdup, but instead limiting callers to a fixed set of values. In preparation for the next commit, the function is renamed from "empty" to "replacement", because it'll be used for more than empty fields. I didn't do the whole string-table setup, because it's all used internally in one file and this way we can immediately assert if an invalid value is passed in. Some callers were (void)ing the error, others were ignoring it, and others propagating. It's nicer to remove the boilerplate.
* uid-range: tie up number and array of uid range entriesYu Watanabe2022-09-161-29/+19
| | | | | | This renames UidRange -> UidRangeEntry, and reintroduces UidRange which contains the array of UidRangeEntry and its size. No fucntional changes, just refactoring.
* userdbctl: fix arrow directionYu Watanabe2022-09-161-4/+4
|
* userdbctl: do not show meaningless boundaries when no uid range availableYu Watanabe2022-09-161-4/+2
|
* tree-wide: port various users over to connect_unix_path()Lennart Poettering2022-05-141-9/+3
| | | | Let's make use of our new helper, and thus allow longer paths.
* userdb: fix error handlingYu Watanabe2022-05-131-1/+1
|
* userdbctl: initialize parameter `n` for uid_range_load_userns()Thomas Weißschuh2022-05-061-2/+2
| | | | | | | uid_range_load_userns() dereferences the n parameter. Passing unitialized memory may lead to crashes, for example with version 251rc2-1 on ArchLinux.
* userdbctl: also show available UID range in current usernsLennart Poettering2022-04-011-14/+206
| | | | | | | | | | | | | Containers generally have a smaller UID range assigned than host systems. Let's visualize this in the user/group tables. We insert markers for unavailable regions. This way display is identical to status quo ante on host systems, but in containers unavailable ranges will be shown as that. And while we are at it, also hide well-known UID ranges when they are outside of userns uid_map range. This is mostly about the "container" range. It's pointless showing the cotnainer range (i.e. a range UID > 65535) if that range isn#t available in the container anyway.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-17/+7
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* userdbctl: add a dash of color to users of different dispositionsLennart Poettering2022-02-161-4/+37
|
* userdbctl: show min/max UID boundaries in userdbctl outputLennart Poettering2022-02-161-12/+198
|
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* userdbctl: add support for chaining command lines in "authorized-keys" verbLennart Poettering2021-11-111-16/+79
|
* userdbctl: always show summary after printing table (unless legend is off)Lennart Poettering2021-11-081-15/+46
| | | | | We do this in many (most?) other tools, do so here too. It's quite useful info to count users/groups/…
* userdbctl: add a switch for explicitly enabling/disabling multiplexer-based ↵Lennart Poettering2021-11-081-0/+11
| | | | | | lookups This is incredibly useful for debugging.
* userdbctl: make JSON output mode details configurable like in the other toolsLennart Poettering2021-11-081-20/+35
| | | | | Let's add --json= with the same parser as in the other tools, and honour it.
* userdbctl: explicitly handle ESRCH/ENOLINK from userdb_all()Lennart Poettering2021-11-081-49/+63
| | | | | | | Similar in style to previous commit, let's handle these two errors properly, i.e. as equivalent to no entries found. Let's debug log about them, to make things either to deal with when debugging (after all userdbctl to a large degree are debugging tools).
* Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-031-1/+1
|
* userdb: fix type to pass to connect()Yu Watanabe2021-10-161-1/+1
| | | | Fixes https://github.com/systemd/systemd/pull/20613#issuecomment-944621275.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-5/+5
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* userdbctl: add two new switches --with-dropin=/--with-varlink=Lennart Poettering2021-05-101-8/+30
| | | | | These directly correspond to the underlying flags. They are useful for testing.
* userdb: rename userdb lookup flags a bitLennart Poettering2021-05-071-2/+2
| | | | | | | | | | | | | Let's use "exclude" for flags that really exclude records from our lookup. Let's use "avoid" referring to concepts that when flag is set we'll not use but we have a fallback path for that should yield the same result. Let' use "suppress" for suppressing partial info, even if we return the record otherwise. So far we used "avoid" for all these cases, which was confusing. Whiel we are at it, let's reassign the bits a bit, leaving some space for bits follow-up commits are going to add.
* table: drop last SIZE_MAX from table_set_sort() and table_set_display()Yu Watanabe2021-03-051-6/+6
|
* tree-wide: use parse_boolean_argument() for variables with non-boolean typeZbigniew Jędrzejewski-Szmek2021-02-171-4/+5
| | | | | This still works nicely, but we need to assign the return value ourselves. As before, one nice effect is that error messages are uniform.
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-5/+5
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* tree-wide: unsetenv cannot failZbigniew Jędrzejewski-Szmek2020-11-101-4/+2
| | | | | | ... when called with a valid environment variable name. This means that any time we call it with a fixed string, it is guaranteed to return 0. (Also when the variable is not present in the environment block.)
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* userdbctl: add forgotten --output mode in helpZbigniew Jędrzejewski-Szmek2020-09-011-1/+2
|
* shared: merge {user,group}-record-show.[ch]Zbigniew Jędrzejewski-Szmek2020-09-011-1/+0
| | | | | It is natural to include both, and in total they declared three functions. Let's merge them for simplicity.
* userdb: add "description" field to group recordsLennart Poettering2020-08-071-2/+4
| | | | | | | | | User records have the realname/gecos fields, groups never had that, but it would really be useful to have it, hence let's add it with similar semantics. We enforce the same syntax as for GECOS, since it's better to start with strict rules and losen them later instead of the opposite.
* table use table_log_print_error() instead of table_log_show_errorfangxiuning2020-07-081-3/+3
|
* table add table_log_show_error()fangxiuning2020-07-081-3/+3
|
* userdbctl homectl use table_log_add_error()fangxiuning2020-07-061-4/+4
| | | | Signed-off-by: fangxiuning <fangxiuning123@126.com>
* log: introduce log_parse_environment_cli() and log_setup_cli()Filipe Brandenburger2020-06-241-3/+1
| | | | | | | | | | | | | | | | Presently, CLI utilities such as systemctl will check whether they have a tty attached or not to decide whether to parse /proc/cmdline or EFI variable SystemdOptions looking for systemd.log_* entries. But this check will be misleading if these tools are being launched by a daemon, such as a monitoring daemon or automation service that runs in background. Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI variables to determine the logging level. Furthermore, introduce a new log_setup_cli() shortcut to set up common options used by most command-line utilities.
* userdbctl: make --help fit in 80 columnsZbigniew Jędrzejewski-Szmek2020-04-281-16/+16
|
* tree-wide: spellcheck using codespellZbigniew Jędrzejewski-Szmek2020-04-161-1/+1
| | | | Fixes #15436.
* userdbctl: drop redundant user name validity checkLennart Poettering2020-04-081-6/+5
| | | | | | | The userdb_by_name() invocation immediately following does the same check anyway, no need to do this twice. (Also, make sure we exit the function early on failure)
* tree-wide: use the return value from sockaddr_un_set_path()Zbigniew Jędrzejewski-Szmek2020-03-021-1/+3
| | | | | | | | | It fully initializes the address structure, so no need for pre-initialization, and also returns the length of the address, so no need to recalculate using SOCKADDR_UN_LEN(). socklen_t is unsigned, so let's not use an int for it. (It doesn't matter, but seems cleaner and more portable to not assume anything about the type.)
* userdb: fix memleakYu Watanabe2020-02-271-1/+1
| | | | Fixes #14947.
* systemd: Fix busctl crash on aarch64 when setting output table formatAlin Popa2020-02-161-6/+6
| | | | | | | | The enum used for column names is integer type while table_set_display() is parsing arguments on size_t alignment which may result in assert in table_set_display() if the size between types missmatch. This patch cast the enums to size_t. It also fixes all other occurences for table_set_display() and table_set_sort().
* userdbd: add userdbctl tool as client for userdbdLennart Poettering2020-01-151-0/+790