about summary refs log tree commit diff
path: root/sunrpc
diff options
context:
space:
mode:
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/clnt_perr.c192
-rw-r--r--sunrpc/des_soft.c12
-rw-r--r--sunrpc/key_call.c24
-rw-r--r--sunrpc/netname.c6
-rw-r--r--sunrpc/openchild.c2
-rw-r--r--sunrpc/pmap_rmt.c2
-rw-r--r--sunrpc/publickey.c6
-rw-r--r--sunrpc/svc_run.c2
-rw-r--r--sunrpc/xcrypt.c2
9 files changed, 164 insertions, 84 deletions
diff --git a/sunrpc/clnt_perr.c b/sunrpc/clnt_perr.c
index d756cb12ba..ae6a1da7e0 100644
--- a/sunrpc/clnt_perr.c
+++ b/sunrpc/clnt_perr.c
@@ -153,47 +153,102 @@ clnt_perror (CLIENT * rpch, const char *msg)
 struct rpc_errtab
 {
   enum clnt_stat status;
-  const char *message;
+  unsigned int message_off;
+};
+
+static const char rpc_errstr[] =
+{
+#define RPC_SUCCESS_IDX		0
+  N_("RPC: Success")
+  "\0"
+#define RPC_CANTENCODEARGS_IDX	(RPC_SUCCESS_IDX + sizeof "RPC: Success")
+  N_("RPC: Can't encode arguments")
+  "\0"
+#define RPC_CANTDECODERES_IDX	(RPC_CANTENCODEARGS_IDX \
+				 + sizeof "RPC: Can't encode arguments")
+  N_("RPC: Can't decode result")
+  "\0"
+#define RPC_CANTSEND_IDX	(RPC_CANTDECODERES_IDX \
+				 + sizeof "RPC: Can't decode result")
+  N_("RPC: Unable to send")
+  "\0"
+#define RPC_CANTRECV_IDX	(RPC_CANTSEND_IDX \
+				 + sizeof "RPC: Unable to send")
+  N_("RPC: Unable to receive")
+  "\0"
+#define RPC_TIMEDOUT_IDX	(RPC_CANTRECV_IDX \
+				 + sizeof "RPC: Unable to receive")
+  N_("RPC: Timed out")
+  "\0"
+#define RPC_VERSMISMATCH_IDX	(RPC_TIMEDOUT_IDX \
+				 + sizeof "RPC: Timed out")
+  N_("RPC: Incompatible versions of RPC")
+  "\0"
+#define RPC_AUTHERROR_IDX	(RPC_VERSMISMATCH_IDX \
+				 + sizeof "RPC: Incompatible versions of RPC")
+  N_("RPC: Authentication error")
+  "\0"
+#define RPC_PROGUNAVAIL_IDX		(RPC_AUTHERROR_IDX \
+				 + sizeof "RPC: Authentication error")
+  N_("RPC: Program unavailable")
+  "\0"
+#define RPC_PROGVERSMISMATCH_IDX (RPC_PROGUNAVAIL_IDX \
+				  + sizeof "RPC: Program unavailable")
+  N_("RPC: Program/version mismatch")
+  "\0"
+#define RPC_PROCUNAVAIL_IDX	(RPC_PROGVERSMISMATCH_IDX \
+				 + sizeof "RPC: Program/version mismatch")
+  N_("RPC: Procedure unavailable")
+  "\0"
+#define RPC_CANTDECODEARGS_IDX	(RPC_PROCUNAVAIL_IDX \
+				 + sizeof "RPC: Procedure unavailable")
+  N_("RPC: Server can't decode arguments")
+  "\0"
+#define RPC_SYSTEMERROR_IDX	(RPC_CANTDECODEARGS_IDX \
+				 + sizeof "RPC: Server can't decode arguments")
+  N_("RPC: Remote system error")
+  "\0"
+#define RPC_UNKNOWNHOST_IDX	(RPC_SYSTEMERROR_IDX \
+				 + sizeof "RPC: Remote system error")
+  N_("RPC: Unknown host")
+  "\0"
+#define RPC_UNKNOWNPROTO_IDX	(RPC_UNKNOWNHOST_IDX \
+				 + sizeof "RPC: Unknown host")
+  N_("RPC: Unknown protocol")
+  "\0"
+#define RPC_PMAPFAILURE_IDX	(RPC_UNKNOWNPROTO_IDX \
+				 + sizeof "RPC: Unknown protocol")
+  N_("RPC: Port mapper failure")
+  "\0"
+#define RPC_PROGNOTREGISTERED_IDX (RPC_PMAPFAILURE_IDX \
+				   + sizeof "RPC: Port mapper failure")
+  N_("RPC: Program not registered")
+  "\0"
+#define RPC_FAILED_IDX		(RPC_PROGNOTREGISTERED_IDX \
+				 + sizeof "RPC: Program not registered")
+  N_("RPC: Failed (unspecified error)")
 };
 
 static const struct rpc_errtab rpc_errlist[] =
 {
-  {RPC_SUCCESS,
-   N_("RPC: Success")},
-  {RPC_CANTENCODEARGS,
-   N_("RPC: Can't encode arguments")},
-  {RPC_CANTDECODERES,
-   N_("RPC: Can't decode result")},
-  {RPC_CANTSEND,
-   N_("RPC: Unable to send")},
-  {RPC_CANTRECV,
-   N_("RPC: Unable to receive")},
-  {RPC_TIMEDOUT,
-   N_("RPC: Timed out")},
-  {RPC_VERSMISMATCH,
-   N_("RPC: Incompatible versions of RPC")},
-  {RPC_AUTHERROR,
-   N_("RPC: Authentication error")},
-  {RPC_PROGUNAVAIL,
-   N_("RPC: Program unavailable")},
-  {RPC_PROGVERSMISMATCH,
-   N_("RPC: Program/version mismatch")},
-  {RPC_PROCUNAVAIL,
-   N_("RPC: Procedure unavailable")},
-  {RPC_CANTDECODEARGS,
-   N_("RPC: Server can't decode arguments")},
-  {RPC_SYSTEMERROR,
-   N_("RPC: Remote system error")},
-  {RPC_UNKNOWNHOST,
-   N_("RPC: Unknown host")},
-  {RPC_UNKNOWNPROTO,
-   N_("RPC: Unknown protocol")},
-  {RPC_PMAPFAILURE,
-   N_("RPC: Port mapper failure")},
-  {RPC_PROGNOTREGISTERED,
-   N_("RPC: Program not registered")},
-  {RPC_FAILED,
-   N_("RPC: Failed (unspecified error)")}
+  { RPC_SUCCESS, RPC_SUCCESS_IDX },
+  { RPC_CANTENCODEARGS, RPC_CANTENCODEARGS_IDX },
+  { RPC_CANTDECODERES, RPC_CANTDECODERES_IDX },
+  { RPC_CANTSEND, RPC_CANTSEND_IDX },
+  { RPC_CANTRECV, RPC_CANTRECV_IDX },
+  { RPC_TIMEDOUT, RPC_TIMEDOUT_IDX },
+  { RPC_VERSMISMATCH, RPC_VERSMISMATCH_IDX },
+  { RPC_AUTHERROR, RPC_AUTHERROR_IDX },
+  { RPC_PROGUNAVAIL, RPC_PROGUNAVAIL_IDX },
+  { RPC_PROGVERSMISMATCH, RPC_PROGVERSMISMATCH },
+  { RPC_PROCUNAVAIL, RPC_PROCUNAVAIL_IDX },
+  { RPC_CANTDECODEARGS, RPC_CANTDECODEARGS_IDX },
+  { RPC_SYSTEMERROR, RPC_SYSTEMERROR_IDX },
+  { RPC_UNKNOWNHOST, RPC_UNKNOWNHOST_IDX },
+  { RPC_UNKNOWNPROTO, RPC_UNKNOWNPROTO_IDX },
+  { RPC_PMAPFAILURE, RPC_PMAPFAILURE_IDX },
+  { RPC_PROGNOTREGISTERED, RPC_PROGNOTREGISTERED_IDX },
+  { RPC_FAILED, RPC_FAILED_IDX }
 };
 
 
@@ -209,7 +264,7 @@ clnt_sperrno (enum clnt_stat stat)
     {
       if (rpc_errlist[i].status == stat)
 	{
-	  return _(rpc_errlist[i].message);
+	  return _(rpc_errstr + rpc_errlist[i].message_off);
 	}
     }
   return _("RPC: (unknown error code)");
@@ -264,27 +319,52 @@ clnt_pcreateerror (const char *msg)
 struct auth_errtab
 {
   enum auth_stat status;
-  const char *message;
+  unsigned int message_off;
+};
+
+static const char auth_errstr[] =
+{
+#define AUTH_OK_IDX		0
+   N_("Authentication OK")
+   "\0"
+#define AUTH_BADCRED_IDX	(AUTH_OK_IDX + sizeof "Authentication OK")
+   N_("Invalid client credential")
+   "\0"
+#define AUTH_REJECTEDCRED_IDX	(AUTH_BADCRED_IDX \
+				 + sizeof "Invalid client credential")
+   N_("Server rejected credential")
+   "\0"
+#define AUTH_BADVERF_IDX	(AUTH_REJECTEDCRED_IDX \
+				 + sizeof "Server rejected credential")
+   N_("Invalid client verifier")
+   "\0"
+#define AUTH_REJECTEDVERF_IDX	(AUTH_BADVERF_IDX \
+				 + sizeof "Invalid client verifier")
+   N_("Server rejected verifier")
+   "\0"
+#define AUTH_TOOWEAK_IDX	(AUTH_REJECTEDVERF_IDX \
+				 + sizeof "Server rejected verifier")
+   N_("Client credential too weak")
+   "\0"
+#define AUTH_INVALIDRESP_IDX	(AUTH_TOOWEAK_IDX \
+				 + sizeof "Client credential too weak")
+   N_("Invalid server verifier")
+   "\0"
+#define AUTH_FAILED_IDX		(AUTH_INVALIDRESP_IDX \
+				 + sizeof "Invalid server verifier")
+   N_("Failed (unspecified error)")
 };
 
 static const struct auth_errtab auth_errlist[] =
 {
-  {AUTH_OK,
-   N_("Authentication OK")},
-  {AUTH_BADCRED,
-   N_("Invalid client credential")},
-  {AUTH_REJECTEDCRED,
-   N_("Server rejected credential")},
-  {AUTH_BADVERF,
-   N_("Invalid client verifier")},
-  {AUTH_REJECTEDVERF,
-   N_("Server rejected verifier")},
-  {AUTH_TOOWEAK,
-   N_("Client credential too weak")},
-  {AUTH_INVALIDRESP,
-   N_("Invalid server verifier")},
-  {AUTH_FAILED,
-   N_("Failed (unspecified error)")},
+  { AUTH_OK, AUTH_OK_IDX },
+  { AUTH_BADCRED, AUTH_BADCRED_IDX },
+  { AUTH_REJECTEDCRED, AUTH_REJECTEDCRED_IDX },
+  { AUTH_BADVERF, AUTH_BADVERF_IDX },
+  { AUTH_REJECTEDVERF, AUTH_REJECTEDVERF_IDX },
+  { AUTH_TOOWEAK, AUTH_TOOWEAK_IDX },
+  { AUTH_INVALIDRESP, AUTH_INVALIDRESP_IDX },
+  { AUTH_FAILED, AUTH_FAILED_IDX }
 };
 
 static char *
@@ -297,7 +377,7 @@ auth_errmsg (enum auth_stat stat)
     {
       if (auth_errlist[i].status == stat)
 	{
-	  return _(auth_errlist[i].message);
+	  return _(auth_errstr + auth_errlist[i].message_off);
 	}
     }
   return NULL;
diff --git a/sunrpc/des_soft.c b/sunrpc/des_soft.c
index ae12d7b0a6..f358cac480 100644
--- a/sunrpc/des_soft.c
+++ b/sunrpc/des_soft.c
@@ -8,23 +8,23 @@ static char sccsid[] = "@(#)des_soft.c	2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/
  * may copy or modify Sun RPC without charge, but are not authorized
  * to license or distribute it to anyone else except as part of a product or
  * program developed by the user.
- * 
+ *
  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
+ *
  * Sun RPC is provided with no support and without any obligation on the
  * part of Sun Microsystems, Inc. to assist in its use, correction,
  * modification or enhancement.
- * 
+ *
  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
@@ -32,7 +32,7 @@ static char sccsid[] = "@(#)des_soft.c	2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/
 /*
  * Table giving odd parity in the low bit for ASCII characters
  */
-static char partab[128] =
+static const char partab[128] =
 {
   0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07,
   0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e,
diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c
index 6157e574b9..5aef933cbf 100644
--- a/sunrpc/key_call.c
+++ b/sunrpc/key_call.c
@@ -59,14 +59,14 @@
 
 #define debug(msg)		/* turn off debugging */
 
-extern int _openchild (char *command, FILE **fto, FILE **ffrom);
+extern int _openchild (const char *command, FILE **fto, FILE **ffrom);
 
 
 static int key_call (u_long, xdrproc_t xdr_arg, char *,
 		     xdrproc_t xdr_rslt, char *) internal_function;
 
-static struct timeval trytimeout = {KEY_TIMEOUT, 0};
-static struct timeval tottimeout = {KEY_TIMEOUT *KEY_NRETRY, 0};
+static const struct timeval trytimeout = {KEY_TIMEOUT, 0};
+static const struct timeval tottimeout = {KEY_TIMEOUT *KEY_NRETRY, 0};
 
 int
 key_setsecret (char *secretkey)
@@ -268,9 +268,9 @@ key_get_conv (char *pkey, des_block *deskey)
  * implementations of these functions, and to call those in key_call().
  */
 
-cryptkeyres *(*__key_encryptsession_pk_LOCAL) (uid_t, char *) = 0;
-cryptkeyres *(*__key_decryptsession_pk_LOCAL) (uid_t, char *) = 0;
-des_block *(*__key_gendes_LOCAL) (uid_t, char *) = 0;
+cryptkeyres *(*__key_encryptsession_pk_LOCAL) (uid_t, char *);
+cryptkeyres *(*__key_decryptsession_pk_LOCAL) (uid_t, char *);
+des_block *(*__key_gendes_LOCAL) (uid_t, char *);
 
 static int
 internal_function
@@ -287,7 +287,7 @@ key_call_keyenvoy (u_long proc, xdrproc_t xdr_arg, char *arg,
   int success;
   uid_t ruid;
   uid_t euid;
-  static char MESSENGER[] = "/usr/etc/keyenvoy";
+  static const char MESSENGER[] = "/usr/etc/keyenvoy";
 
   success = 1;
   sigemptyset (&mask);
@@ -355,7 +355,7 @@ struct  key_call_private {
   pid_t   pid;            /* process-id at moment of creation */
   uid_t   uid;            /* user-id at last authorization */
 };
-static struct key_call_private *key_call_private_main = NULL;
+static struct key_call_private *key_call_private_main;
 __libc_lock_define_initialized (static, keycall_lock)
 
 /*
@@ -555,9 +555,9 @@ internal_function
 key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
 	  xdrproc_t xdr_rslt, char *rslt)
 {
-  static int use_keyenvoy = 0;
+  static int use_keyenvoy;
 #ifdef HAVE_DOORS
-  static int use_doors = 1;
+  static int not_use_doors;
 #endif
 
   if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL)
@@ -583,11 +583,11 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
     }
 
 #ifdef HAVE_DOORS
-  if (use_doors)
+  if (!not_use_doors)
     {
       if (key_call_door (proc, xdr_arg, arg, xdr_rslt, rslt))
 	return 1;
-      use_doors = 0;
+      not_use_doors = 1;
     }
 #endif
   if (!use_keyenvoy)
diff --git a/sunrpc/netname.c b/sunrpc/netname.c
index 1578108194..3a2025da09 100644
--- a/sunrpc/netname.c
+++ b/sunrpc/netname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -26,7 +26,7 @@
 
 #define	OPSYS_LEN 4
 #define	MAXIPRINT (11)		/* max length of printed integer */
-static const char *OPSYS = "unix";
+static const char OPSYS[] = "unix";
 
 int
 user2netname (char netname[MAXNETNAMELEN + 1], const uid_t uid,
@@ -141,7 +141,7 @@ int
 netname2user (const char netname[MAXNETNAMELEN + 1], uid_t * uidp, gid_t * gidp,
 	      int *gidlenp, gid_t * gidlist)
 {
-  static service_user *startp = NULL;
+  static service_user *startp;
   static netname2user_function start_fct;
   service_user *nip;
   netname2user_function fct;
diff --git a/sunrpc/openchild.c b/sunrpc/openchild.c
index 8399b261bd..4b5a0a5f24 100644
--- a/sunrpc/openchild.c
+++ b/sunrpc/openchild.c
@@ -53,7 +53,7 @@
  * returns pid, or -1 for failure
  */
 int
-_openchild (char *command, FILE ** fto, FILE ** ffrom)
+_openchild (const char *command, FILE ** fto, FILE ** ffrom)
 {
   int i;
   int pid;
diff --git a/sunrpc/pmap_rmt.c b/sunrpc/pmap_rmt.c
index c35540e06e..f361ac3598 100644
--- a/sunrpc/pmap_rmt.c
+++ b/sunrpc/pmap_rmt.c
@@ -58,7 +58,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
 
 extern u_long _create_xid (void);
 
-static struct timeval timeout = {3, 0};
+static const struct timeval timeout = {3, 0};
 
 /*
  * pmapper remote-call-service interface.
diff --git a/sunrpc/publickey.c b/sunrpc/publickey.c
index 16664b6714..94d5499b98 100644
--- a/sunrpc/publickey.c
+++ b/sunrpc/publickey.c
@@ -1,5 +1,5 @@
 /* Get public or secret key from key server.
-   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -38,7 +38,7 @@ extern int __nss_publickey_lookup (service_user **nip, const char *name,
 int
 getpublickey (const char *name, char *key)
 {
-  static service_user *startp = NULL;
+  static service_user *startp;
   static public_function start_fct;
   service_user *nip;
   public_function fct;
@@ -76,7 +76,7 @@ getpublickey (const char *name, char *key)
 int
 getsecretkey (const char *name, char *key, const char *passwd)
 {
-  static service_user *startp = NULL;
+  static service_user *startp;
   static secret_function start_fct;
   service_user *nip;
   secret_function fct;
diff --git a/sunrpc/svc_run.c b/sunrpc/svc_run.c
index 1a76b10183..d854fb4f2c 100644
--- a/sunrpc/svc_run.c
+++ b/sunrpc/svc_run.c
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
 #include <errno.h>
 #include <rpc/rpc.h>
 
-static int svc_stop = 0;
+static int svc_stop;
 
 /* This function can be used as a signal handler to terminate the
    server loop.  */
diff --git a/sunrpc/xcrypt.c b/sunrpc/xcrypt.c
index bee38ad8b5..a6b2499708 100644
--- a/sunrpc/xcrypt.c
+++ b/sunrpc/xcrypt.c
@@ -50,7 +50,7 @@ static char sccsid[] = "@(#)xcrypt.c 1.3 89/03/24 Copyr 1986 Sun Micro";
 #include <sys/types.h>
 #include <rpc/des_crypt.h>
 
-static char hex[16] =
+static const char hex[16] =
 {
   '0', '1', '2', '3', '4', '5', '6', '7',
   '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',