ipa-client code cleanup

Fixes errors about implicit function declaration and moves duplicated
gettext code into a common module. Also silences some warnings.

Signed-off-by: Simo Sorce <ssorce@redhat.com>
This commit is contained in:
Jakub Hrozek authored and Simo Sorce committed 2010-11-22 16:01:35 -05:00
1 parent 7086c9e863
commit 960fc66447
7 files changed
+73 -98

No files matched your search

+3
View File
@@ -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)
+3 -27
View File
@@ -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;
}
+48
View File
@@ -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;
}
+9
View File
@@ -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 */
+5 -31
View File
@@ -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;
+2 -11
View File
@@ -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;
+3 -29
View File
@@ -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") },