summaryrefslogtreecommitdiffstats
path: root/source/torture/nsstest.c
diff options
context:
space:
mode:
authorCVS Import User <samba-bugs@samba.org>2004-04-04 11:51:10 +0000
committerCVS Import User <samba-bugs@samba.org>2004-04-04 11:51:10 +0000
commite3d2dbdff6711b0bc768fb6b08f41240f21d5fba (patch)
tree159ef54b59b18e9b950f5c6af105915214244912 /source/torture/nsstest.c
parent139b1658ca30692835c1a7203c7cd003e587ac12 (diff)
downloadsamba-e3d2dbdff6711b0bc768fb6b08f41240f21d5fba.tar.gz
samba-e3d2dbdff6711b0bc768fb6b08f41240f21d5fba.tar.xz
samba-e3d2dbdff6711b0bc768fb6b08f41240f21d5fba.zip
r6: merge in the samba4 HEAD branch from cvs
to checkout try: svn co svn+ssh://svn.samba.org/home/svn/samba/branches/SAMBA_4_0 metze
Diffstat (limited to 'source/torture/nsstest.c')
-rw-r--r--source/torture/nsstest.c67
1 files changed, 13 insertions, 54 deletions
diff --git a/source/torture/nsstest.c b/source/torture/nsstest.c
index a803cd7e719..a82fa05203e 100644
--- a/source/torture/nsstest.c
+++ b/source/torture/nsstest.c
@@ -2,7 +2,6 @@
Unix SMB/CIFS implementation.
nss tester for winbindd
Copyright (C) Andrew Tridgell 2001
- Copyright (C) Tim Potter 2003
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
@@ -29,11 +28,11 @@ static int total_errors;
static void *find_fn(const char *name)
{
- pstring s;
+ char s[1024];
static void *h;
void *res;
- pstr_sprintf(s, "_nss_%s_%s", nss_name, name);
+ snprintf(s,sizeof(s), "_nss_%s_%s", nss_name, name);
if (!h) {
h = sys_dlopen(so_path, RTLD_LAZY);
@@ -45,7 +44,6 @@ static void *find_fn(const char *name)
res = sys_dlsym(h, s);
if (!res) {
printf("Can't find function %s\n", s);
- total_errors++;
return NULL;
}
return res;
@@ -67,9 +65,6 @@ static struct passwd *nss_getpwent(void)
static char buf[1000];
NSS_STATUS status;
- if (!_nss_getpwent_r)
- return NULL;
-
status = _nss_getpwent_r(&pwd, buf, sizeof(buf), &nss_errno);
if (status == NSS_STATUS_NOTFOUND) {
return NULL;
@@ -88,9 +83,6 @@ static struct passwd *nss_getpwnam(const char *name)
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
-
- if (!_nss_getpwnam_r)
- return NULL;
status = _nss_getpwnam_r(name, &pwd, buf, sizeof(buf), &nss_errno);
if (status == NSS_STATUS_NOTFOUND) {
@@ -110,9 +102,6 @@ static struct passwd *nss_getpwuid(uid_t uid)
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
-
- if (!_nss_getpwuid_r)
- return NULL;
status = _nss_getpwuid_r(uid, &pwd, buf, sizeof(buf), &nss_errno);
if (status == NSS_STATUS_NOTFOUND) {
@@ -129,10 +118,6 @@ static void nss_setpwent(void)
{
NSS_STATUS (*_nss_setpwent)(void) = find_fn("setpwent");
NSS_STATUS status;
-
- if (!_nss_setpwent)
- return;
-
status = _nss_setpwent();
if (status != NSS_STATUS_SUCCESS) {
report_nss_error("setpwent", status);
@@ -143,10 +128,6 @@ static void nss_endpwent(void)
{
NSS_STATUS (*_nss_endpwent)(void) = find_fn("endpwent");
NSS_STATUS status;
-
- if (!_nss_endpwent)
- return;
-
status = _nss_endpwent();
if (status != NSS_STATUS_SUCCESS) {
report_nss_error("endpwent", status);
@@ -163,11 +144,7 @@ static struct group *nss_getgrent(void)
static int buflen = 1024;
NSS_STATUS status;
- if (!_nss_getgrent_r)
- return NULL;
-
- if (!buf)
- buf = malloc(buflen);
+ if (!buf) buf = malloc(buflen);
again:
status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
@@ -195,11 +172,7 @@ static struct group *nss_getgrnam(const char *name)
static int buflen = 1000;
NSS_STATUS status;
- if (!_nss_getgrnam_r)
- return NULL;
-
- if (!buf)
- buf = malloc(buflen);
+ if (!buf) buf = malloc(buflen);
again:
status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
@@ -226,12 +199,7 @@ static struct group *nss_getgrgid(gid_t gid)
static int buflen = 1000;
NSS_STATUS status;
- if (!_nss_getgrgid_r)
- return NULL;
-
- if (!buf)
- buf = malloc(buflen);
-
+ if (!buf) buf = malloc(buflen);
again:
status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
@@ -253,10 +221,6 @@ static void nss_setgrent(void)
{
NSS_STATUS (*_nss_setgrent)(void) = find_fn("setgrent");
NSS_STATUS status;
-
- if (!_nss_setgrent)
- return;
-
status = _nss_setgrent();
if (status != NSS_STATUS_SUCCESS) {
report_nss_error("setgrent", status);
@@ -267,10 +231,6 @@ static void nss_endgrent(void)
{
NSS_STATUS (*_nss_endgrent)(void) = find_fn("endgrent");
NSS_STATUS status;
-
- if (!_nss_endgrent)
- return;
-
status = _nss_endgrent();
if (status != NSS_STATUS_SUCCESS) {
report_nss_error("endgrent", status);
@@ -284,8 +244,7 @@ static int nss_initgroups(char *user, gid_t group, gid_t **groups, long int *sta
find_fn("initgroups_dyn");
NSS_STATUS status;
- if (!_nss_initgroups)
- return NSS_STATUS_UNAVAIL;
+ if (!_nss_initgroups) return NSS_STATUS_UNAVAIL;
status = _nss_initgroups(user, group, start, size, groups, 0, &nss_errno);
if (status != NSS_STATUS_SUCCESS) {
@@ -296,11 +255,11 @@ static int nss_initgroups(char *user, gid_t group, gid_t **groups, long int *sta
static void print_passwd(struct passwd *pwd)
{
- printf("%s:%s:%lu:%lu:%s:%s:%s\n",
+ printf("%s:%s:%d:%d:%s:%s:%s\n",
pwd->pw_name,
pwd->pw_passwd,
- (unsigned long)pwd->pw_uid,
- (unsigned long)pwd->pw_gid,
+ pwd->pw_uid,
+ pwd->pw_gid,
pwd->pw_gecos,
pwd->pw_dir,
pwd->pw_shell);
@@ -309,10 +268,10 @@ static void print_passwd(struct passwd *pwd)
static void print_group(struct group *grp)
{
int i;
- printf("%s:%s:%lu: ",
+ printf("%s:%s:%d: ",
grp->gr_name,
grp->gr_passwd,
- (unsigned long)grp->gr_gid);
+ grp->gr_gid);
if (!grp->gr_mem[0]) {
printf("\n");
@@ -343,9 +302,9 @@ static void nss_test_initgroups(char *name, gid_t gid)
}
for (i=0; i<start-1; i++) {
- printf("%lu, ", (unsigned long)groups[i]);
+ printf("%d, ", groups[i]);
}
- printf("%lu\n", (unsigned long)groups[i]);
+ printf("%d\n", groups[i]);
}