]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - lib/shells.c
2 * SPDX-License-Identifier: GPL-2.0-or-later
4 #include <sys/syslog.h>
5 #if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
9 #include "closestream.h"
12 #if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
13 static econf_file
*open_etc_shells(void)
16 econf_file
*key_file
= NULL
;
18 error
= econf_readDirs(&key_file
,
27 _("Cannot parse shells files: %s"),
28 econf_errString(error
));
37 * print_shells () -- /etc/shells is outputted to stdout.
39 extern void print_shells(FILE *out
, const char *format
)
41 #if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
45 econf_file
*key_file
= open_etc_shells();
50 error
= econf_getKeys(key_file
, NULL
, &size
, &keys
);
54 _("Cannot evaluate entries in shells files: %s"),
55 econf_errString(error
));
58 for (size_t i
= 0; i
< size
; i
++) {
59 fprintf(out
, format
, keys
[i
]);
66 while ((s
= getusershell()))
67 fprintf(out
, format
, s
);
74 * is_known_shell() -- if the given shell appears in /etc/shells
75 * or vendor defined files.
76 * Return 1 if found and return 0 if not found.
78 extern int is_known_shell(const char *shell_name
)
85 #if defined (HAVE_LIBECONF) && defined (USE_VENDORDIR)
88 econf_file
*key_file
= open_etc_shells();
93 error
= econf_getStringValue (key_file
, NULL
, shell_name
, &val
);
95 if (error
!= ECONF_NOKEY
)
97 _("Cannot evaluate entries in shells files: %s"),
98 econf_errString(error
));
103 econf_free(key_file
);
108 while ((s
= getusershell())) {
109 if (*s
!= '#' && strcmp(shell_name
, s
) == 0) {