Clean up: the use of identifiers called "access" and "daemon" shadow
function declarations in unistd.h. Seen with "-Wextra -pedantic".
tcpwrapper.c: In function haccess_add:
tcpwrapper.c:112: warning: declaration of access shadows a global
declaration /usr/include/unistd.h:288: warning: shadowed declaration is here
tcpwrapper.c: In function good_client:
tcpwrapper.c:161: warning: declaration of daemon shadows a global declaration
/usr/include/unistd.h:953: warning: shadowed declaration is here
tcpwrapper.c: In function check_default:
tcpwrapper.c:212: warning: declaration of daemon shadows a
global declaration
/usr/include/unistd.h:953: warning: shadowed declaration is here
good_client() is used only in support/misc/tcpwrapper.c, so make it
static (and update its prototype to c99 standard form).
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-extern int good_client(char *daemon, struct sockaddr_in *addr);
extern int from_local(const struct sockaddr *sap);
extern int from_local(const struct sockaddr *sap);
-extern int check_default(char *daemon, struct sockaddr_in *addr, u_long prog);
+extern int check_default(char *name, struct sockaddr_in *addr, u_long prog);
#endif /* TCP_WRAPPER_H */
#endif /* TCP_WRAPPER_H */
#define DENY 0
typedef struct _haccess_t {
#define DENY 0
typedef struct _haccess_t {
- TAILQ_ENTRY(_haccess_t) list;
- int access;
- struct in_addr addr;
+ TAILQ_ENTRY(_haccess_t) list;
+ int allowed;
+ struct in_addr addr;
} haccess_t;
#define HASH_TABLE_SIZE 1021
} haccess_t;
#define HASH_TABLE_SIZE 1021
} hash_head;
hash_head haccess_tbl[HASH_TABLE_SIZE];
static haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long);
} hash_head;
hash_head haccess_tbl[HASH_TABLE_SIZE];
static haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long);
-static void haccess_add(struct sockaddr_in *addr, u_long, int);
static unsigned long
strtoint(const char *str)
static unsigned long
strtoint(const char *str)
return hashint(strtoint(addr) + program);
}
return hashint(strtoint(addr) + program);
}
-void haccess_add(struct sockaddr_in *addr, u_long prog, int access)
+static void
+haccess_add(struct sockaddr_in *addr, u_long prog, int allowed)
{
hash_head *head;
haccess_t *hptr;
{
hash_head *head;
haccess_t *hptr;
hash = HASH(inet_ntoa(addr->sin_addr), prog);
head = &(haccess_tbl[hash]);
hash = HASH(inet_ntoa(addr->sin_addr), prog);
head = &(haccess_tbl[hash]);
+ hptr->allowed = allowed;
hptr->addr.s_addr = addr->sin_addr.s_addr;
if (TAILQ_EMPTY(&head->h_head))
hptr->addr.s_addr = addr->sin_addr.s_addr;
if (TAILQ_EMPTY(&head->h_head))
-int
-good_client(daemon, addr)
-char *daemon;
-struct sockaddr_in *addr;
+static int
+good_client(char *name, struct sockaddr_in *addr)
{
struct request_info req;
{
struct request_info req;
- request_init(&req, RQ_DAEMON, daemon, RQ_CLIENT_SIN, addr, 0);
+ request_init(&req, RQ_DAEMON, name, RQ_CLIENT_SIN, addr, 0);
sock_methods(&req);
if (hosts_access(&req))
sock_methods(&req);
if (hosts_access(&req))
/**
* check_default - additional checks for NULL, DUMP, GETPORT and unknown
/**
* check_default - additional checks for NULL, DUMP, GETPORT and unknown
- * @daemon: pointer to '\0'-terminated ASCII string containing name of the
+ * @name: pointer to '\0'-terminated ASCII string containing name of the
* daemon requesting the access check
* @addr: pointer to socket address containing address of caller
* @prog: RPC program number caller is attempting to access
* daemon requesting the access check
* @addr: pointer to socket address containing address of caller
* @prog: RPC program number caller is attempting to access
* Returns TRUE if the caller is allowed access; otherwise FALSE is returned.
*/
int
* Returns TRUE if the caller is allowed access; otherwise FALSE is returned.
*/
int
-check_default(char *daemon, struct sockaddr_in *addr, u_long prog)
+check_default(char *name, struct sockaddr_in *addr, u_long prog)
{
haccess_t *acc = NULL;
int changed = check_files();
acc = haccess_lookup(addr, prog);
if (acc && changed == 0)
{
haccess_t *acc = NULL;
int changed = check_files();
acc = haccess_lookup(addr, prog);
if (acc && changed == 0)
- if (!(from_local((struct sockaddr *)addr) || good_client(daemon, addr))) {
+ if (!(from_local((struct sockaddr *)addr) || good_client(name, addr))) {
else
haccess_add(addr, prog, FALSE);
return (FALSE);
}
if (acc)
else
haccess_add(addr, prog, FALSE);
return (FALSE);
}
if (acc)
else
haccess_add(addr, prog, TRUE);
else
haccess_add(addr, prog, TRUE);