summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-26 17:24:56 -0800
committerJeremy Allison <jra@samba.org>2007-11-26 17:24:56 -0800
commit80c2446321c519797a57b8006942a983f8481d79 (patch)
tree1b3cc43b7cbcb2b1688027364f99291993467046 /source3/nsswitch
parentd5b2325fcd597813b081d17161d26d85110c100b (diff)
downloadsamba-80c2446321c519797a57b8006942a983f8481d79.tar.gz
samba-80c2446321c519797a57b8006942a983f8481d79.tar.bz2
samba-80c2446321c519797a57b8006942a983f8481d79.zip
Remove pstrings from nsswitch/ and registry/
Jeremy. (This used to be commit 331c0d6216e1a1607a49ed7eb4078e10138ec16a)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wb_common.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/source3/nsswitch/wb_common.c b/source3/nsswitch/wb_common.c
index 2ae85dcb1e..49a2935bff 100644
--- a/source3/nsswitch/wb_common.c
+++ b/source3/nsswitch/wb_common.c
@@ -168,54 +168,51 @@ static int winbind_named_pipe_sock(const char *dir)
{
struct sockaddr_un sunaddr;
struct stat st;
- pstring path;
+ char *path = NULL;
int fd;
int wait_time;
int slept;
-
+
/* Check permissions on unix socket directory */
-
+
if (lstat(dir, &st) == -1) {
return -1;
}
-
- if (!S_ISDIR(st.st_mode) ||
+
+ if (!S_ISDIR(st.st_mode) ||
(st.st_uid != 0 && st.st_uid != geteuid())) {
return -1;
}
-
+
/* Connect to socket */
-
- strncpy(path, dir, sizeof(path) - 1);
- path[sizeof(path) - 1] = '\0';
-
- strncat(path, "/", sizeof(path) - 1 - strlen(path));
- path[sizeof(path) - 1] = '\0';
-
- strncat(path, WINBINDD_SOCKET_NAME, sizeof(path) - 1 - strlen(path));
- path[sizeof(path) - 1] = '\0';
-
+
+ if (asprintf(&path, "%s/%s", dir, WINBINDD_SOCKET_NAME) < 0) {
+ return -1;
+ }
+
ZERO_STRUCT(sunaddr);
sunaddr.sun_family = AF_UNIX;
strncpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path) - 1);
-
+
/* If socket file doesn't exist, don't bother trying to connect
with retry. This is an attempt to make the system usable when
the winbindd daemon is not running. */
if (lstat(path, &st) == -1) {
+ SAFE_FREE(path);
return -1;
}
-
+
+ SAFE_FREE(path);
/* Check permissions on unix socket file */
-
- if (!S_ISSOCK(st.st_mode) ||
+
+ if (!S_ISSOCK(st.st_mode) ||
(st.st_uid != 0 && st.st_uid != geteuid())) {
return -1;
}
-
+
/* Connect to socket */
-
+
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
return -1;
}