diff -uwrN samba-3.0.4.orig/source/client/mount.cifs.c samba-3.0.4/source/client/mount.cifs.c --- samba-3.0.4.orig/source/client/mount.cifs.c 2004-04-28 23:34:49.000000000 -0800 +++ samba-3.0.4/source/client/mount.cifs.c 2004-06-05 07:23:12.510131200 -0800 @@ -769,6 +769,7 @@ return -1; } +#ifndef __CYGWIN__ if((getuid() != 0) && (geteuid() == 0)) { if((statbuf.st_uid == getuid()) && (S_IRWXU == (statbuf.st_mode & S_IRWXU))) { #ifndef CIFS_ALLOW_USR_SUID @@ -781,6 +782,7 @@ return -1; } } +#endif if(got_user == 0) user_name = getusername(); diff -uwrN samba-3.0.4.orig/source/client/smbmnt.c samba-3.0.4/source/client/smbmnt.c --- samba-3.0.4.orig/source/client/smbmnt.c 2004-04-03 23:37:28.000000000 -0800 +++ samba-3.0.4/source/client/smbmnt.c 2004-06-05 07:23:12.560203200 -0800 @@ -126,12 +126,14 @@ return -1; } +#ifndef __CYGWIN__ if ((getuid() != 0) && ((getuid() != st.st_uid) || ((st.st_mode & S_IRWXU) != S_IRWXU))) { errno = EPERM; return -1; } +#endif return 0; } diff -uwrN samba-3.0.4.orig/source/client/smbumount.c samba-3.0.4/source/client/smbumount.c --- samba-3.0.4.orig/source/client/smbumount.c 2004-04-03 23:37:28.000000000 -0800 +++ samba-3.0.4/source/client/smbumount.c 2004-06-05 07:23:12.580232000 -0800 @@ -53,12 +53,14 @@ return -1; } +#ifndef __CYGWIN__ if ((getuid() != 0) && (mount_uid != getuid())) { fprintf(stderr, "You are not allowed to umount %s\n", mount_point); return -1; } +#endif close(fid); return 0; diff -uwrN samba-3.0.4.orig/source/configure.in samba-3.0.4/source/configure.in --- samba-3.0.4.orig/source/configure.in 2004-04-28 23:34:48.000000000 -0800 +++ samba-3.0.4/source/configure.in 2004-06-05 07:30:17.581353600 -0800 @@ -12,7 +12,7 @@ # Directory handling stuff to support both the # legacy SAMBA directories and FHS compliant # ones... -AC_PREFIX_DEFAULT(/usr/local/samba) +AC_PREFIX_DEFAULT(z:/samba) lockdir="\${VARDIR}/locks" piddir="\${VARDIR}/locks" @@ -362,6 +362,9 @@ dnl These are preferably build shared, and static if dlopen() is not available default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437" +default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_recycle vfs_audit vfs_extd_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap charset_CP850 charset_CP437" +default_shared_modules="" + if test "x$developer" = xyes; then default_static_modules="$default_static_modules rpc_echo" default_shared_modules="$default_shared_modules charset_weird" @@ -1272,6 +1275,14 @@ AC_DEFINE(STAT_ST_BLOCKSIZE,512) ;; + *cygwin*) AC_DEFINE(CYGWINOS,1,[Whether the host os is Cygwin]) + BLDSHARED="true" + LDSHFLAGS="-shared -Wl,--export-all-symbols" + SHLIBEXT="dll" + AC_DEFINE(STAT_ST_BLOCKSIZE,512) + dnl LDSHFLAGS="-shared -Wl,--export-all-symbols -Wl,--out-implib=libmydll.dll.a" + ;; + *) AC_DEFINE(STAT_ST_BLOCKSIZE,512) ;; diff -uwrN samba-3.0.4.orig/source/include/config.h.in samba-3.0.4/source/include/config.h.in --- samba-3.0.4.orig/source/include/config.h.in 2004-05-07 16:33:46.000000000 -0800 +++ samba-3.0.4/source/include/config.h.in 2004-06-05 07:23:12.760491200 -0800 @@ -18,6 +18,9 @@ /* Whether the compiler supports the LL prefix on long long integers */ #undef COMPILER_SUPPORTS_LL +/* Whether the host os is Cygwin */ +#undef CYGWINOS + /* Whether the host os is Darwin/MacOSX */ #undef DARWINOS diff -uwrN samba-3.0.4.orig/source/lib/smbrun.c samba-3.0.4/source/lib/smbrun.c --- samba-3.0.4.orig/source/lib/smbrun.c 2004-04-03 23:37:35.000000000 -0800 +++ samba-3.0.4/source/lib/smbrun.c 2004-06-05 07:23:12.790534400 -0800 @@ -155,6 +155,7 @@ become_user_permanently(uid, gid); +#ifndef __CYGWIN__ if (getuid() != uid || geteuid() != uid || getgid() != gid || getegid() != gid) { /* we failed to lose our privileges - do not execute @@ -162,6 +163,7 @@ exit(81); /* we can't print stuff at this stage, instead use exit codes for debugging */ } +#endif #ifndef __INSURE__ /* close all other file descriptors, leaving only 0, 1 and 2. 0 and diff -uwrN samba-3.0.4.orig/source/lib/util_sec.c samba-3.0.4/source/lib/util_sec.c --- samba-3.0.4.orig/source/lib/util_sec.c 2004-04-03 23:37:34.000000000 -0800 +++ samba-3.0.4/source/lib/util_sec.c 2004-06-05 07:23:12.810563200 -0800 @@ -87,6 +87,7 @@ ****************************************************************************/ static void assert_uid(uid_t ruid, uid_t euid) { +#ifndef __CYGWIN__ if ((euid != (uid_t)-1 && geteuid() != euid) || (ruid != (uid_t)-1 && getuid() != ruid)) { if (!non_root_mode()) { @@ -97,6 +98,7 @@ exit(1); } } +#endif } /**************************************************************************** @@ -104,6 +106,7 @@ ****************************************************************************/ static void assert_gid(gid_t rgid, gid_t egid) { +#ifndef __CYGWIN__ if ((egid != (gid_t)-1 && getegid() != egid) || (rgid != (gid_t)-1 && getgid() != rgid)) { if (!non_root_mode()) { @@ -115,6 +118,7 @@ exit(1); } } +#endif } /**************************************************************************** @@ -424,6 +428,7 @@ main() { +#ifndef __CYGWIN__ if (getuid() != 0) { #if (defined(AIX) && defined(USE_SETREUID)) /* setreuid is badly broken on AIX 4.1, we avoid it completely */ @@ -436,6 +441,7 @@ fprintf(stderr,"not running as root: checking for ENOSYS\n"); exit(have_syscall()); } +#endif gain_root_privilege(); gain_root_group_privilege(); @@ -446,11 +452,13 @@ gain_root_privilege(); gain_root_group_privilege(); become_user_permanently(1, 1); +#ifndef __CYGWIN__ setuid(0); if (getuid() == 0) { fprintf(stderr,"uid not set permanently\n"); exit(1); } +#endif printf("OK\n"); @@ -463,5 +471,9 @@ ****************************************************************************/ BOOL is_setuid_root(void) { +#ifndef __CYGWIN__ return (geteuid() == (uid_t)0) && (getuid() != (uid_t)0); +#else + return 0; +#endif } diff -uwrN samba-3.0.4.orig/source/pam_smbpass/pam_smb_passwd.c samba-3.0.4/source/pam_smbpass/pam_smb_passwd.c --- samba-3.0.4.orig/source/pam_smbpass/pam_smb_passwd.c 2004-04-03 23:37:33.000000000 -0800 +++ samba-3.0.4/source/pam_smbpass/pam_smb_passwd.c 2004-06-05 07:23:12.830592000 -0800 @@ -165,7 +165,11 @@ /* Password change by root, or for an expired token, doesn't require authentication. Is this a good choice? */ - if (getuid() != 0 && !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) { + if ( +#ifndef __CYGWIN__ + getuid() != 0 && +#endif + !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) { /* tell user what is happening */ #define greeting "Changing password for " diff -uwrN samba-3.0.4.orig/source/popt/poptconfig.c samba-3.0.4/source/popt/poptconfig.c --- samba-3.0.4.orig/source/popt/poptconfig.c 2004-04-03 23:37:16.000000000 -0800 +++ samba-3.0.4/source/popt/poptconfig.c 2004-06-05 07:23:12.850620800 -0800 @@ -126,7 +126,9 @@ rc = poptReadConfigFile(con, "/etc/popt"); if (rc) return rc; +#ifndef __CYGWIN__ if (getuid() != geteuid()) return 0; +#endif if ((home = getenv("HOME"))) { fn = malloc(strlen(home) + 20); diff -uwrN samba-3.0.4.orig/source/tests/summary.c samba-3.0.4/source/tests/summary.c --- samba-3.0.4.orig/source/tests/summary.c 2004-04-03 23:37:33.000000000 -0800 +++ samba-3.0.4/source/tests/summary.c 2004-06-05 07:23:12.870649600 -0800 @@ -2,10 +2,12 @@ main() { +#ifndef __CYGWIN32__ #if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64)) printf("ERROR: No locking available. Running Samba would be unsafe\n"); exit(1); #endif +#endif #if !(defined(HAVE_IFACE_IFCONF) || defined(HAVE_IFACE_IFREQ) || defined(HAVE_IFACE_AIX)) printf("WARNING: No automated network interface determination\n"); diff -uwrN samba-3.0.4.orig/source/utils/net_groupmap.c samba-3.0.4/source/utils/net_groupmap.c --- samba-3.0.4.orig/source/utils/net_groupmap.c 2004-04-20 12:42:58.000000000 -0800 +++ samba-3.0.4/source/utils/net_groupmap.c 2004-06-05 07:23:12.910707200 -0800 @@ -752,10 +752,12 @@ }; /* we shouldn't have silly checks like this */ +#ifndef __CYGWIN__ if (getuid() != 0) { d_printf("You must be root to edit group mappings.\nExiting...\n"); return -1; } +#endif if ( argc ) return net_run_function(argc, argv, func, net_help_groupmap); diff -uwrN samba-3.0.4.orig/source/utils/smbpasswd.c samba-3.0.4/source/utils/smbpasswd.c --- samba-3.0.4.orig/source/utils/smbpasswd.c 2004-04-03 23:37:38.000000000 -0800 +++ samba-3.0.4/source/utils/smbpasswd.c 2004-06-05 07:23:12.960779200 -0800 @@ -583,9 +583,13 @@ set_auth_parameters(argc, argv); #endif /* HAVE_SET_AUTH_PARAMETERS */ +#ifndef __CYGWIN__ if (getuid() == 0) { +#endif local_flags = LOCAL_AM_ROOT; +#ifndef __CYGWIN__ } +#endif local_flags = process_options(argc, argv, local_flags); diff -uwrN samba-3.0.4.orig/source/utils/status.c samba-3.0.4/source/utils/status.c --- samba-3.0.4.orig/source/utils/status.c 2004-04-03 23:37:38.000000000 -0800 +++ samba-3.0.4/source/utils/status.c 2004-06-05 07:23:12.990822400 -0800 @@ -599,10 +599,12 @@ dbf = x_stderr; +#ifndef __CYGWIN__ if (getuid() != geteuid()) { d_printf("smbstatus should not be run setuid\n"); return(1); } +#endif pc = poptGetContext(NULL, argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); diff -uwrN samba-3.0.4.orig/source/web/cgi.c samba-3.0.4/source/web/cgi.c --- samba-3.0.4.orig/source/web/cgi.c 2004-04-03 23:37:22.000000000 -0800 +++ samba-3.0.4/source/web/cgi.c 2004-06-05 07:23:13.010851200 -0800 @@ -299,6 +299,7 @@ exit(0); } +#ifndef __CYGWIN__ setuid(0); setuid(pwd->pw_uid); if (geteuid() != pwd->pw_uid || getuid() != pwd->pw_uid) { @@ -306,6 +307,7 @@ head, user, (int)geteuid(), (int)getuid(), tail); exit(0); } +#endif passwd_free(&pwd); }