diff options
-rw-r--r-- | ipa-client/Makefile.am | 3 | ||||
-rw-r--r-- | ipa-client/config.c | 30 | ||||
-rw-r--r-- | ipa-client/ipa-client-common.c | 48 | ||||
-rw-r--r-- | ipa-client/ipa-client-common.h | 9 | ||||
-rw-r--r-- | ipa-client/ipa-getkeytab.c | 36 | ||||
-rw-r--r-- | ipa-client/ipa-join.c | 13 | ||||
-rw-r--r-- | ipa-client/ipa-rmkeytab.c | 32 |
7 files changed, 73 insertions, 98 deletions
diff --git a/ipa-client/Makefile.am b/ipa-client/Makefile.am index ebb9a8392..7d152fbfd 100644 --- a/ipa-client/Makefile.am +++ b/ipa-client/Makefile.am @@ -42,6 +42,7 @@ sbin_PROGRAMS = \ ipa_getkeytab_SOURCES = \ ipa-getkeytab.c \ + ipa-client-common.c \ $(KRB5_UTIL_SRCS) \ $(NULL) @@ -55,6 +56,7 @@ ipa_getkeytab_LDADD = \ ipa_rmkeytab_SOURCES = \ ipa-rmkeytab.c \ + ipa-client-common.c \ $(NULL) ipa_rmkeytab_LDADD = \ @@ -64,6 +66,7 @@ ipa_rmkeytab_LDADD = \ ipa_join_SOURCES = \ config.c \ + ipa-client-common.c \ ipa-join.c \ $(NULL) diff --git a/ipa-client/config.c b/ipa-client/config.c index 69bd9cb33..31060e39f 100644 --- a/ipa-client/config.c +++ b/ipa-client/config.c @@ -39,8 +39,8 @@ #include <errno.h> #include "config.h" -#include <libintl.h> -#define _(STRING) gettext(STRING) + +#include "ipa-client-common.h" char * read_config_file(const char *filename) @@ -88,7 +88,7 @@ read_config_file(const char *filename) char * get_config_entry(char * in_data, const char *section, const char *key) { - char *ptr, *p, *tmp; + char *ptr = NULL, *p, *tmp; char *line; int in_section = 0; char * data; @@ -164,27 +164,3 @@ get_config_entry(char * in_data, const char *section, const char *key) free(data); return NULL; } - -int init_gettext(void) -{ - char *c; - - c = setlocale(LC_ALL, ""); - if (!c) { - return EIO; - } - - errno = 0; - c = bindtextdomain(PACKAGE, LOCALEDIR); - if (c == NULL) { - return errno; - } - - errno = 0; - c = textdomain(PACKAGE); - if (c == NULL) { - return errno; - } - - return 0; -} diff --git a/ipa-client/ipa-client-common.c b/ipa-client/ipa-client-common.c new file mode 100644 index 000000000..d7b623078 --- /dev/null +++ b/ipa-client/ipa-client-common.c @@ -0,0 +1,48 @@ +/* Authors: Jakub Hrozek <jhrozek@redhat.com> + * + * Copyright (C) 2010 Red Hat + * see file 'COPYING' for use and warranty information + * + * This program 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; version 2 only + * + * This program 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <locale.h> +#include <libintl.h> +#include <errno.h> + +#include "config.h" + +int init_gettext(void) +{ + char *c; + + c = setlocale(LC_ALL, ""); + if (!c) { + return EIO; + } + + errno = 0; + c = bindtextdomain(PACKAGE, LOCALEDIR); + if (c == NULL) { + return errno; + } + + errno = 0; + c = textdomain(PACKAGE); + if (c == NULL) { + return errno; + } + + return 0; +} diff --git a/ipa-client/ipa-client-common.h b/ipa-client/ipa-client-common.h new file mode 100644 index 000000000..dbf474d52 --- /dev/null +++ b/ipa-client/ipa-client-common.h @@ -0,0 +1,9 @@ +#ifndef __IPA_CLIENT_COMMON_H +#define __IPA_CLIENT_COMMON_H + +#include <libintl.h> +#define _(STRING) gettext(STRING) + +int init_gettext(void); + +#endif /* __IPA_CLIENT_COMMON_H */ diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c index 19f8b21d6..2f9d09bf8 100644 --- a/ipa-client/ipa-getkeytab.c +++ b/ipa-client/ipa-getkeytab.c @@ -41,10 +41,9 @@ #include <popt.h> #include "config.h" -#include <libintl.h> -#define _(STRING) gettext(STRING) #include "ipa_krb5.h" +#include "ipa-client-common.h" /* Salt types */ #define NO_SALT -1 @@ -229,7 +228,7 @@ static int prep_ksdata(krb5_context krbctx, const char *str, * MIT code do anyway */ for (i = 0, n = 0; i < nkeys; i++ ) { - int similar = 0; + krb5_boolean similar = 0; for (j = 0; j < i; j++) { krberr = krb5_c_enctype_compare(krbctx, @@ -275,7 +274,7 @@ static int create_keys(krb5_context krbctx, krb5_error_code krberr; krb5_data key_password; krb5_data *realm; - int i, j, nkeys; + int i, nkeys; int ret; ret = prep_ksdata(krbctx, enctypes_string, keys); @@ -751,31 +750,7 @@ static char *ask_password(krb5_context krbctx) return password; } -int init_gettext(void) -{ - char *c; - - c = setlocale(LC_ALL, ""); - if (!c) { - return EIO; - } - - errno = 0; - c = bindtextdomain(PACKAGE, LOCALEDIR); - if (c == NULL) { - return errno; - } - - errno = 0; - c = textdomain(PACKAGE); - if (c == NULL) { - return errno; - } - - return 0; -} - -int main(int argc, char *argv[]) +int main(int argc, const char *argv[]) { static const char *server = NULL; static const char *principal = NULL; @@ -805,7 +780,7 @@ int main(int argc, char *argv[]) _("Show the list of permitted encryption types and exit"), _("Permitted Encryption Types") }, { "password", 'P', POPT_ARG_NONE, &askpass, 0, - _("Asks for a non-random password to use for the principal") }, + _("Asks for a non-random password to use for the principal"), NULL }, { "binddn", 'D', POPT_ARG_STRING, &binddn, 0, _("LDAP DN"), _("DN to bind as if not using kerberos") }, { "bindpw", 'w', POPT_ARG_STRING, &bindpw, 0, @@ -821,7 +796,6 @@ int main(int argc, char *argv[]) krb5_principal uprinc; krb5_principal sprinc; krb5_error_code krberr; - ber_int_t *enctypes; struct keys_container keys; krb5_keytab kt; int kvno; diff --git a/ipa-client/ipa-join.c b/ipa-client/ipa-join.c index e67f29b81..01afa1ad0 100644 --- a/ipa-client/ipa-join.c +++ b/ipa-client/ipa-join.c @@ -38,8 +38,7 @@ #include "xmlrpc-c/base.h" #include "xmlrpc-c/client.h" -#include <libintl.h> -#define _(STRING) gettext(STRING) +#include "ipa-client-common.h" #define NAME "ipa-join" #define VERSION "1.0" @@ -82,14 +81,6 @@ getIPAserver(char * data) { return get_config_entry(data, "global", "server"); } -/* Get the IPA realm from the configuration file. - * The caller is responsible for freeing this value - */ -static char * -getIPArealm(char * data) { - return get_config_entry(data, "global", "realm"); -} - /* Make sure that the keytab is writable before doing anything */ static int check_perms(const char *keytab) { @@ -951,7 +942,7 @@ cleanup: * unique (host already added). */ int -main(int argc, char **argv) { +main(int argc, const char **argv) { static const char *hostname = NULL; static const char *server = NULL; static const char *keytab = NULL; diff --git a/ipa-client/ipa-rmkeytab.c b/ipa-client/ipa-rmkeytab.c index c46bb8b6c..1ccf67327 100644 --- a/ipa-client/ipa-rmkeytab.c +++ b/ipa-client/ipa-rmkeytab.c @@ -25,10 +25,8 @@ #include <popt.h> #include <errno.h> +#include "ipa-client-common.h" #include "config.h" -#include <libintl.h> -#define _(STRING) gettext(STRING) - int remove_principal(krb5_context context, krb5_keytab ktid, const char *principal, int debug) @@ -143,32 +141,8 @@ done: return rval; } -int init_gettext(void) -{ - char *c; - - c = setlocale(LC_ALL, ""); - if (!c) { - return EIO; - } - - errno = 0; - c = bindtextdomain(PACKAGE, LOCALEDIR); - if (c == NULL) { - return errno; - } - - errno = 0; - c = textdomain(PACKAGE); - if (c == NULL) { - return errno; - } - - return 0; -} - int -main(int argc, char **argv) +main(int argc, const char **argv) { krb5_context context; krb5_error_code krberr; @@ -180,7 +154,7 @@ main(int argc, char **argv) static const char *principal = NULL; static const char *realm = NULL; int debug = 0; - int ret, rval; + int ret, rval = 0; struct poptOption options[] = { { "debug", 'd', POPT_ARG_NONE, &debug, 0, _("Print debugging information"), _("Debugging output") }, |