mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-12 16:32:01 -05:00
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:
1 parent
7086c9e863
commit
960fc66447
7 files changed
+73
-98
No files matched your search
@@ -42,6 +42,7 @@ sbin_PROGRAMS = \
|
|||||||
|
|
||||||
ipa_getkeytab_SOURCES = \
|
ipa_getkeytab_SOURCES = \
|
||||||
ipa-getkeytab.c \
|
ipa-getkeytab.c \
|
||||||
|
ipa-client-common.c \
|
||||||
$(KRB5_UTIL_SRCS) \
|
$(KRB5_UTIL_SRCS) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ ipa_getkeytab_LDADD = \
|
|||||||
|
|
||||||
ipa_rmkeytab_SOURCES = \
|
ipa_rmkeytab_SOURCES = \
|
||||||
ipa-rmkeytab.c \
|
ipa-rmkeytab.c \
|
||||||
|
ipa-client-common.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ipa_rmkeytab_LDADD = \
|
ipa_rmkeytab_LDADD = \
|
||||||
@@ -64,6 +66,7 @@ ipa_rmkeytab_LDADD = \
|
|||||||
|
|
||||||
ipa_join_SOURCES = \
|
ipa_join_SOURCES = \
|
||||||
config.c \
|
config.c \
|
||||||
|
ipa-client-common.c \
|
||||||
ipa-join.c \
|
ipa-join.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|||||||
+3
-27
@@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <libintl.h>
|
|
||||||
#define _(STRING) gettext(STRING)
|
#include "ipa-client-common.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
read_config_file(const char *filename)
|
read_config_file(const char *filename)
|
||||||
@@ -88,7 +88,7 @@ read_config_file(const char *filename)
|
|||||||
char *
|
char *
|
||||||
get_config_entry(char * in_data, const char *section, const char *key)
|
get_config_entry(char * in_data, const char *section, const char *key)
|
||||||
{
|
{
|
||||||
char *ptr, *p, *tmp;
|
char *ptr = NULL, *p, *tmp;
|
||||||
char *line;
|
char *line;
|
||||||
int in_section = 0;
|
int in_section = 0;
|
||||||
char * data;
|
char * data;
|
||||||
@@ -164,27 +164,3 @@ get_config_entry(char * in_data, const char *section, const char *key)
|
|||||||
free(data);
|
free(data);
|
||||||
return NULL;
|
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;
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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 */
|
||||||
@@ -41,10 +41,9 @@
|
|||||||
#include <popt.h>
|
#include <popt.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <libintl.h>
|
|
||||||
#define _(STRING) gettext(STRING)
|
|
||||||
|
|
||||||
#include "ipa_krb5.h"
|
#include "ipa_krb5.h"
|
||||||
|
#include "ipa-client-common.h"
|
||||||
|
|
||||||
/* Salt types */
|
/* Salt types */
|
||||||
#define NO_SALT -1
|
#define NO_SALT -1
|
||||||
@@ -229,7 +228,7 @@ static int prep_ksdata(krb5_context krbctx, const char *str,
|
|||||||
* MIT code do anyway */
|
* MIT code do anyway */
|
||||||
|
|
||||||
for (i = 0, n = 0; i < nkeys; i++ ) {
|
for (i = 0, n = 0; i < nkeys; i++ ) {
|
||||||
int similar = 0;
|
krb5_boolean similar = 0;
|
||||||
|
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
krberr = krb5_c_enctype_compare(krbctx,
|
krberr = krb5_c_enctype_compare(krbctx,
|
||||||
@@ -275,7 +274,7 @@ static int create_keys(krb5_context krbctx,
|
|||||||
krb5_error_code krberr;
|
krb5_error_code krberr;
|
||||||
krb5_data key_password;
|
krb5_data key_password;
|
||||||
krb5_data *realm;
|
krb5_data *realm;
|
||||||
int i, j, nkeys;
|
int i, nkeys;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = prep_ksdata(krbctx, enctypes_string, keys);
|
ret = prep_ksdata(krbctx, enctypes_string, keys);
|
||||||
@@ -751,31 +750,7 @@ static char *ask_password(krb5_context krbctx)
|
|||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_gettext(void)
|
int main(int argc, const char *argv[])
|
||||||
{
|
|
||||||
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[])
|
|
||||||
{
|
{
|
||||||
static const char *server = NULL;
|
static const char *server = NULL;
|
||||||
static const char *principal = 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"),
|
_("Show the list of permitted encryption types and exit"),
|
||||||
_("Permitted Encryption Types") },
|
_("Permitted Encryption Types") },
|
||||||
{ "password", 'P', POPT_ARG_NONE, &askpass, 0,
|
{ "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,
|
{ "binddn", 'D', POPT_ARG_STRING, &binddn, 0,
|
||||||
_("LDAP DN"), _("DN to bind as if not using kerberos") },
|
_("LDAP DN"), _("DN to bind as if not using kerberos") },
|
||||||
{ "bindpw", 'w', POPT_ARG_STRING, &bindpw, 0,
|
{ "bindpw", 'w', POPT_ARG_STRING, &bindpw, 0,
|
||||||
@@ -821,7 +796,6 @@ int main(int argc, char *argv[])
|
|||||||
krb5_principal uprinc;
|
krb5_principal uprinc;
|
||||||
krb5_principal sprinc;
|
krb5_principal sprinc;
|
||||||
krb5_error_code krberr;
|
krb5_error_code krberr;
|
||||||
ber_int_t *enctypes;
|
|
||||||
struct keys_container keys;
|
struct keys_container keys;
|
||||||
krb5_keytab kt;
|
krb5_keytab kt;
|
||||||
int kvno;
|
int kvno;
|
||||||
|
|||||||
+2
-11
@@ -38,8 +38,7 @@
|
|||||||
#include "xmlrpc-c/base.h"
|
#include "xmlrpc-c/base.h"
|
||||||
#include "xmlrpc-c/client.h"
|
#include "xmlrpc-c/client.h"
|
||||||
|
|
||||||
#include <libintl.h>
|
#include "ipa-client-common.h"
|
||||||
#define _(STRING) gettext(STRING)
|
|
||||||
|
|
||||||
#define NAME "ipa-join"
|
#define NAME "ipa-join"
|
||||||
#define VERSION "1.0"
|
#define VERSION "1.0"
|
||||||
@@ -82,14 +81,6 @@ getIPAserver(char * data) {
|
|||||||
return get_config_entry(data, "global", "server");
|
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 */
|
/* Make sure that the keytab is writable before doing anything */
|
||||||
static int check_perms(const char *keytab)
|
static int check_perms(const char *keytab)
|
||||||
{
|
{
|
||||||
@@ -951,7 +942,7 @@ cleanup:
|
|||||||
* unique (host already added).
|
* unique (host already added).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
main(int argc, char **argv) {
|
main(int argc, const char **argv) {
|
||||||
static const char *hostname = NULL;
|
static const char *hostname = NULL;
|
||||||
static const char *server = NULL;
|
static const char *server = NULL;
|
||||||
static const char *keytab = NULL;
|
static const char *keytab = NULL;
|
||||||
|
|||||||
@@ -25,10 +25,8 @@
|
|||||||
#include <popt.h>
|
#include <popt.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "ipa-client-common.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <libintl.h>
|
|
||||||
#define _(STRING) gettext(STRING)
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
remove_principal(krb5_context context, krb5_keytab ktid, const char *principal, int debug)
|
remove_principal(krb5_context context, krb5_keytab ktid, const char *principal, int debug)
|
||||||
@@ -143,32 +141,8 @@ done:
|
|||||||
return rval;
|
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
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
krb5_context context;
|
krb5_context context;
|
||||||
krb5_error_code krberr;
|
krb5_error_code krberr;
|
||||||
@@ -180,7 +154,7 @@ main(int argc, char **argv)
|
|||||||
static const char *principal = NULL;
|
static const char *principal = NULL;
|
||||||
static const char *realm = NULL;
|
static const char *realm = NULL;
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
int ret, rval;
|
int ret, rval = 0;
|
||||||
struct poptOption options[] = {
|
struct poptOption options[] = {
|
||||||
{ "debug", 'd', POPT_ARG_NONE, &debug, 0,
|
{ "debug", 'd', POPT_ARG_NONE, &debug, 0,
|
||||||
_("Print debugging information"), _("Debugging output") },
|
_("Print debugging information"), _("Debugging output") },
|
||||||
|
|||||||
Reference in new issue
Block a user