#include "portable.h"
#include <stdio.h>
-#include <pwd.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/krb.h>
#include <ac/string.h>
#include <ac/time.h>
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
#include <lber.h>
#include <ldap.h>
#include <ldapconfig.h>
char **rdns; /* for fiddling with the DN */
int authmethod;
int name_provided; /* was a name passed in? */
+#ifdef HAVE_GETPWUID
struct passwd *pw; /* for getting user id */
+#else
+ char *user;
+#endif
char uidname[20];
#ifdef HAVE_KERBEROS
char **krbnames; /* for kerberos names */
* The user needs to bind. If <who> is not specified, we
* assume that authenticating as user id is what user wants.
*/
- if (who == NULL && implicit && (pw = getpwuid((uid_t)geteuid()))
- != (struct passwd *) NULL) {
- sprintf(uidname, "uid=%s", pw->pw_name);
- /* who = pw->pw_name; /* */
- who = uidname;
+ if (who == NULL && implicit) {
+ uidname[0] = '\0';
+
+#ifdef HAVE_GETPWUID
+ if ((pw = getpwuid((uid_t)geteuid())) != (struct passwd *) NULL) {
+ sprintf(uidname, "uid=%s", pw->pw_name);
+ }
+#else
+ user = getenv("USER");
+ if(user == NULL) user = getenv("USERNAME");
+ if(user == NULL) user = getenv("LOGNAME");
+
+ if(user != NULL) {
+ sprintf(uidname, "uid=%s", user);
+ }
+#endif
+
+ if(uidname[0] != '\0') {
+ who = uidname;
+ }
}
if ( who == NULL ) {
#include <ac/time.h>
#include <ac/wait.h>
+#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
+#endif
+#ifdef HAVE_PROCESS_H
+#include <process.h>
+#endif
#include <lber.h>
#include <ldap.h>
++p;
}
printf(" Using %s as the editor...\n", p );
+#ifndef HAVE_SPAWNLP
sleep(2);
+#endif
}
+#ifdef HAVE_SPAWNLP
+ rc = _spawnlp( _P_WAIT, editor, editor, entry_temp_file, NULL );
+ if(rc != 0) {
+ fatal("spawnlp");
+ }
+#else
if ((pid = fork()) == 0) {
/* child - edit the Directory entry */
(void) SIGNAL(SIGINT, SIG_IGN);
fatal("fork");
/*NOTREACHED*/
}
+#endif
return(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
+
+#ifdef HAVE_PWD_H
#include <pwd.h>
+#endif
#include <ac/signal.h>
#include <ac/string.h>
* A per-user config file has precedence over any system-wide
* config file, if one exists.
*/
+#ifdef HAVE_GETPWUID_H
if ((pw = getpwuid((uid_t) geteuid())) == (struct passwd *) NULL)
config = config_file;
else {
config = config_file;
}
}
+#endif /* getpwduid() */
#ifdef DEBUG
if (debug & D_INITIALIZE)
printf("Using config file %s\n", config);
--- /dev/null
+# Microsoft Developer Studio Project File - Name="ud" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ud - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ud.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ud.mak" CFG="ud - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ud - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ud - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ud - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 oldap32.lib olber32.lib oldif32.lib olutil32.lib ws2_32.lib hs_regex.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "ud - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 oldap32.lib olber32.lib oldif32.lib olutil32.lib ws2_32.lib hs_regex.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\libraries\Debug"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ud - Win32 Release"
+# Name "ud - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\auth.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\edit.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\find.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\globals.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\group.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\help.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\main.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\mod.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\print.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\string_to_key.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\ud.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\util.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\Version.c
+# End Source File
+# End Target
+# End Project
--- /dev/null
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "liblber"=..\..\libraries\liblber\liblber.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "libldap"=..\..\libraries\libldap\libldap.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "liblutil"=..\..\libraries\liblutil\liblutil.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "ud"=.\ud.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name liblber
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name libldap
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name liblutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
char * mygetpass(prompt)
char *prompt;
{
-#if defined(DOS) || defined(VMS)
+#if !defined(HAVE_TERMIOS) || !defined(HAVE_SGTTY_H)
static char buf[256];
int i, c;