[PATCH] Make use of posix_openpty() for UNIX password changing code

Brad Smith brad at comstyle.com
Thu Jan 10 13:10:42 MST 2013


The attached patch makes use of posix_openpt() in the findpty() function used
within the UNIX password changing code.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- next part --------------
diff --git a/source3/configure.in b/source3/configure.in
index bd3bffe..3591131 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -970,7 +970,7 @@ AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetg
 AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf)
 AC_CHECK_FUNCS(getgrset)
 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups syscall sysconf)
-AC_CHECK_FUNCS(atexit grantpt posix_fallocate)
+AC_CHECK_FUNCS(atexit grantpt posix_openpt posix_fallocate)
 AC_CHECK_FUNCS(fallocate)
 AC_CHECK_FUNCS(fseeko setluid getpwanam)
 AC_CHECK_FUNCS(fdopendir)
diff --git a/source3/rpc_server/samr/srv_samr_chgpasswd.c b/source3/rpc_server/samr/srv_samr_chgpasswd.c
index 51c0d0f..532da7f 100644
--- a/source3/rpc_server/samr/srv_samr_chgpasswd.c
+++ b/source3/rpc_server/samr/srv_samr_chgpasswd.c
@@ -73,8 +73,12 @@ static int findpty(char **slave)
 	*slave = NULL;
 
 #if defined(HAVE_GRANTPT)
+#if defined(HAVE_POSIX_OPENPT)
+	if ((master = posix_openpt(O_RDWR|O_NOCTTY)) >= 0) {
+#else
 	/* Try to open /dev/ptmx. If that fails, fall through to old method. */
 	if ((master = open("/dev/ptmx", O_RDWR, 0)) >= 0) {
+#endif
 		grantpt(master);
 		unlockpt(master);
 		line = (char *)ptsname(master);


More information about the samba-technical mailing list