[PATCH] Make use of posix_openpty() for UNIX password changing code
Volker Lendecke
Volker.Lendecke at SerNet.DE
Fri Jan 11 04:31:21 MST 2013
On Thu, Jan 10, 2013 at 03:10:42PM -0500, Brad Smith wrote:
> The attached patch makes use of posix_openpt() in the findpty() function used
> within the UNIX password changing code.
Does the attached patchset also work for you? It splits up
the ugly if-condition and adds the configure check to the
waf build as well.
With best regards,
Volker Lendecke
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From f1ac79ec61e3a4121ced20ed21f71242281d1941 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 11 Jan 2013 10:31:42 +0100
Subject: [PATCH 1/2] samr: Split up an assignment from an if condition
---
source3/rpc_server/samr/srv_samr_chgpasswd.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/source3/rpc_server/samr/srv_samr_chgpasswd.c b/source3/rpc_server/samr/srv_samr_chgpasswd.c
index 51c0d0f..3d04899 100644
--- a/source3/rpc_server/samr/srv_samr_chgpasswd.c
+++ b/source3/rpc_server/samr/srv_samr_chgpasswd.c
@@ -74,7 +74,8 @@ static int findpty(char **slave)
#if defined(HAVE_GRANTPT)
/* Try to open /dev/ptmx. If that fails, fall through to old method. */
- if ((master = open("/dev/ptmx", O_RDWR, 0)) >= 0) {
+ master = open("/dev/ptmx", O_RDWR, 0);
+ if (master >= 0) {
grantpt(master);
unlockpt(master);
line = (char *)ptsname(master);
--
1.7.3.4
From df25b9731ebac5554b1c0d6ded9d51d648a45e85 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 11 Jan 2013 10:36:04 +0100
Subject: [PATCH 2/2] samr: Make use of posix_openpt
---
source3/configure.in | 2 +-
source3/rpc_server/samr/srv_samr_chgpasswd.c | 4 ++++
source3/wscript | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
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 3d04899..db1f459 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)
+ master = posix_openpt(O_RDWR|O_NOCTTY);
+#else
/* Try to open /dev/ptmx. If that fails, fall through to old method. */
master = open("/dev/ptmx", O_RDWR, 0);
+#endif
if (master >= 0) {
grantpt(master);
unlockpt(master);
diff --git a/source3/wscript b/source3/wscript
index 9a1cd68..5078716 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -81,7 +81,7 @@ def configure(conf):
conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
- conf.CHECK_FUNCS('atexit grantpt fallocate posix_fallocate')
+ conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
conf.CHECK_FUNCS('fseeko setluid')
conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
conf.CHECK_FUNCS('fdopendir')
--
1.7.3.4
More information about the samba-technical
mailing list