This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
qmail cygwin port successfull
- From: linamat at moldtelecom dot md
- To: cygwin at cygwin dot com
- Date: Wed, 28 May 2003 14:25:28 +0300 (EEST)
- Subject: qmail cygwin port successfull
I am successfully ported qmail-1.03 and it seems to work good.
I've replaced flock() with fcntl() such as somebody did from one japan site.
Problem with spooling (absent mkfifo() and UNIX named pipe implementation
under Cygwin) was resolved by turning to UNIX socket. The only one problem
that the first message is not triggered immediately after sending, but
with the next all OK.
And now in my ISP filials where Win2k lives qmail+vpopmail+mysql under
Win32 works.
Here is a only qmail patch.
I can send Win32 binaries
======cut======
Allow work under CYGWIN
Copyright Samsi Sergey, 2003, linamat@moldtelecom.md
*** qmail-1.03-orig/Makefile Wed May 14 13:49:27 2003
--- qmail-1.03/Makefile Wed May 14 14:20:23 2003
***************
*** 308,314 ****
clean: \
TARGETS
! rm -f `cat TARGETS`
coe.o: \
compile coe.c coe.h
--- 308,314 ----
clean: \
TARGETS
! rm -f `cat TARGETS` *.exe
coe.o: \
compile coe.c coe.h
***************
*** 403,410 ****
alloc.a error.a fs.a str.a
( ( ./compile tryrsolv.c && ./load tryrsolv dns.o \
ipalloc.o ip.o stralloc.a alloc.a error.a fs.a str.a \
! -lresolv `cat socket.lib` ) >/dev/null 2>&1 \
! && echo -lresolv || exit 0 ) > dns.lib
rm -f tryrsolv.o tryrsolv
dns.o: \
--- 403,410 ----
alloc.a error.a fs.a str.a
( ( ./compile tryrsolv.c && ./load tryrsolv dns.o \
ipalloc.o ip.o stralloc.a alloc.a error.a fs.a str.a \
! -I/usr/local/bind/include -L/usr/local/bind/lib -lbind `cat
socket.lib`
) >/dev/null 2>&1 \
! && echo "-I/usr/local/bind/include -L/usr/local/bind/lib -lbind" ||
exit 0 ) > dns.lib
rm -f tryrsolv.o tryrsolv
dns.o: \
*** qmail-1.03-orig/TARGETS Wed May 14 13:49:27 2003
--- qmail-1.03/TARGETS Wed May 14 14:23:19 2003
***************
*** 262,268 ****
qmail-smtpd.o
qmail-smtpd
sendmail.o
- sendmail
tcp-env.o
remoteinfo.o
tcp-env
--- 262,267 ----
***************
*** 316,322 ****
install.o
install-big
hier.o
- install
instcheck.o
instcheck
home
--- 315,320 ----
*** qmail-1.03-orig/chkspawn.c Wed May 14 13:49:26 2003
--- qmail-1.03/chkspawn.c Wed May 14 14:07:49 2003
***************
*** 42,48 ****
--- 42,53 ----
substdio_put(subfderr,num,fmt_ulong(num,(unsigned long) auto_spawn));
substdio_puts(subfderr,".\n");
substdio_flush(subfderr);
+ #ifndef __CYGWIN__
+ /* oops, incorrect value in header.
+ * Although allow Win32 default FD_SET() limit (512)
+ */
_exit(1);
+ #endif
}
_exit(0);
}
*** qmail-1.03-orig/conf-qmail Wed May 14 13:49:30 2003
--- qmail-1.03/conf-qmail Sat Apr 26 10:28:50 2003
***************
*** 1 ****
! /opt/home/mail/usr/qmail
--- 1 ----
! /opt/home/qmail
*** qmail-1.03-orig/conf-spawn Wed May 14 13:49:30 2003
--- qmail-1.03/conf-spawn Sat Apr 26 10:36:19 2003
***************
*** 1 ****
! 509
--- 1 ----
! 512
*** qmail-1.03-orig/conf-users Mon Jun 15 13:53:16 1998
--- qmail-1.03/conf-users Sat May 3 08:55:57 2003
***************
*** 1,7 ****
alias
qmaild
qmaill
! root
qmailp
qmailq
qmailr
--- 1,7 ----
alias
qmaild
qmaill
! Administrator
qmailp
qmailq
qmailr
*** qmail-1.03-orig/dns.c Wed May 14 13:49:26 2003
--- qmail-1.03/dns.c Wed May 14 14:05:11 2003
***************
*** 2,9 ****
--- 2,15 ----
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
+ #ifndef __CYGWIN__
#include <arpa/nameser.h>
#include <resolv.h>
+ #else
+ /* you need specify where */
+ #include "/usr/local/bind/include/arpa/nameser.h"
+ #include "/usr/local/bind/include/resolv.h"
+ #endif
#include <errno.h>
extern int res_query();
extern int res_search();
*** qmail-1.03-orig/hier.c Wed May 14 13:49:25 2003
--- qmail-1.03/hier.c Wed May 14 14:32:17 2003
***************
*** 64,70 ****
--- 64,72 ----
d(auto_qmail,"queue/lock",auto_uidq,auto_gidq,0750);
z(auto_qmail,"queue/lock/tcpto",1024,auto_uidr,auto_gidq,0644);
z(auto_qmail,"queue/lock/sendmutex",0,auto_uids,auto_gidq,0600);
+ #ifndef __CYGWIN__
p(auto_qmail,"queue/lock/trigger",auto_uids,auto_gidq,0622);
+ #endif
c(auto_qmail,"boot","home",auto_uido,auto_gidq,0755);
c(auto_qmail,"boot","home+df",auto_uido,auto_gidq,0755);
***************
*** 101,106 ****
--- 103,128 ----
c(auto_qmail,"doc","PIC.relaygood",auto_uido,auto_gidq,0644);
c(auto_qmail,"doc","PIC.rem2local",auto_uido,auto_gidq,0644);
+ #ifdef __CYGWIN__
+ c(auto_qmail,"bin","qmail-queue.exe",auto_uidq,auto_gidq,04711);
+ c(auto_qmail,"bin","qmail-lspawn.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-start.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-getpw.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-local.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-remote.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-rspawn.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-clean.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-send.exe",auto_uido,auto_gidq,0711);
+ #ifdef EXTERNAL_TODO
+ c(auto_qmail,"bin","qmail-todo.exe",auto_uido,auto_gidq,0711);
+ #endif
+ c(auto_qmail,"bin","splogger.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-newu.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-newmrh.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-pw2u.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-inject.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","predate.exe",auto_uido,auto_gidq,0755);
+ #else
c(auto_qmail,"bin","qmail-queue",auto_uidq,auto_gidq,04711);
c(auto_qmail,"bin","qmail-lspawn",auto_uido,auto_gidq,0700);
c(auto_qmail,"bin","qmail-start",auto_uido,auto_gidq,0700);
***************
*** 119,129 ****
--- 141,180 ----
c(auto_qmail,"bin","qmail-pw2u",auto_uido,auto_gidq,0711);
c(auto_qmail,"bin","qmail-inject",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","predate",auto_uido,auto_gidq,0755);
+ #endif
c(auto_qmail,"bin","datemail",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","mailsubj",auto_uido,auto_gidq,0755);
+ #ifdef __CYGWIN__
+ c(auto_qmail,"bin","qmail-showctl.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qread.exe",auto_uido,auto_gidq,0755);
+ #else
c(auto_qmail,"bin","qmail-showctl",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-qread",auto_uido,auto_gidq,0755);
+ #endif
c(auto_qmail,"bin","qmail-qstat",auto_uido,auto_gidq,0755);
+ #ifdef __CYGWIN__
+ c(auto_qmail,"bin","qmail-tcpto.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-tcpok.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-pop3d.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-popup.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-qmqpc.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qmqpd.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qmtpd.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-smtpd.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","sendmail.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","tcp-env.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qreceipt.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qsmhook.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qbiff.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","forward.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","preline.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","condredirect.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","bouncesaying.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","except.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","maildirmake.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","maildir2mbox.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","maildirwatch.exe",auto_uido,auto_gidq,0755);
+ #else
c(auto_qmail,"bin","qmail-tcpto",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-tcpok",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-pop3d",auto_uido,auto_gidq,0755);
***************
*** 145,150 ****
--- 196,202 ----
c(auto_qmail,"bin","maildirmake",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","maildir2mbox",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","maildirwatch",auto_uido,auto_gidq,0755);
+ #endif
c(auto_qmail,"bin","qail",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","elq",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","pinq",auto_uido,auto_gidq,0755);
*** qmail-1.03-orig/install-big.c Wed May 14 13:49:25 2003
--- qmail-1.03/install-big.c Wed May 14 14:31:31 2003
***************
*** 29,35 ****
--- 29,37 ----
void hier()
{
+ #ifndef __CYGWIN
h(auto_qmail,auto_uido,auto_gidq,0755);
+ #endif
d(auto_qmail,"control",auto_uido,auto_gidq,0755);
d(auto_qmail,"users",auto_uido,auto_gidq,0755);
***************
*** 62,68 ****
--- 64,72 ----
d(auto_qmail,"queue/lock",auto_uidq,auto_gidq,0750);
z(auto_qmail,"queue/lock/tcpto",1024,auto_uidr,auto_gidq,0644);
z(auto_qmail,"queue/lock/sendmutex",0,auto_uids,auto_gidq,0600);
+ #ifndef __CYGWIN__
p(auto_qmail,"queue/lock/trigger",auto_uids,auto_gidq,0622);
+ #endif
c(auto_qmail,"boot","home",auto_uido,auto_gidq,0755);
c(auto_qmail,"boot","home+df",auto_uido,auto_gidq,0755);
***************
*** 99,104 ****
--- 103,128 ----
c(auto_qmail,"doc","PIC.relaygood",auto_uido,auto_gidq,0644);
c(auto_qmail,"doc","PIC.rem2local",auto_uido,auto_gidq,0644);
+ #ifdef __CYGWIN__
+ c(auto_qmail,"bin","qmail-queue.exe",auto_uidq,auto_gidq,04711);
+ c(auto_qmail,"bin","qmail-lspawn.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-start.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-getpw.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-local.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-remote.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-rspawn.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-clean.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-send.exe",auto_uido,auto_gidq,0711);
+ #ifdef EXTERNAL_TODO
+ c(auto_qmail,"bin","qmail-todo.exe",auto_uido,auto_gidq,0711);
+ #endif
+ c(auto_qmail,"bin","splogger.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-newu.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-newmrh.exe",auto_uido,auto_gidq,0700);
+ c(auto_qmail,"bin","qmail-pw2u.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-inject.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","predate.exe",auto_uido,auto_gidq,0755);
+ #else
c(auto_qmail,"bin","qmail-queue",auto_uidq,auto_gidq,04711);
c(auto_qmail,"bin","qmail-lspawn",auto_uido,auto_gidq,0700);
c(auto_qmail,"bin","qmail-start",auto_uido,auto_gidq,0700);
***************
*** 117,124 ****
--- 141,175 ----
c(auto_qmail,"bin","qmail-pw2u",auto_uido,auto_gidq,0711);
c(auto_qmail,"bin","qmail-inject",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","predate",auto_uido,auto_gidq,0755);
+ #endif
c(auto_qmail,"bin","datemail",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","mailsubj",auto_uido,auto_gidq,0755);
+ #ifdef __CYGWIN__
+ c(auto_qmail,"bin","qmail-showctl.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qread.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qstat",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-tcpto.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-tcpok.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-pop3d.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-popup.exe",auto_uido,auto_gidq,0711);
+ c(auto_qmail,"bin","qmail-qmqpc.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qmqpd.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-qmtpd.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qmail-smtpd.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","sendmail.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","tcp-env.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qreceipt.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qsmhook.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","qbiff.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","forward.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","preline.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","condredirect.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","bouncesaying.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","except.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","maildirmake.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","maildir2mbox.exe",auto_uido,auto_gidq,0755);
+ c(auto_qmail,"bin","maildirwatch.exe",auto_uido,auto_gidq,0755);
+ #else
c(auto_qmail,"bin","qmail-showctl",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-qread",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","qmail-qstat",auto_uido,auto_gidq,0755);
***************
*** 143,148 ****
--- 194,200 ----
c(auto_qmail,"bin","maildirmake",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","maildir2mbox",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","maildirwatch",auto_uido,auto_gidq,0755);
+ #endif
c(auto_qmail,"bin","qail",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","elq",auto_uido,auto_gidq,0755);
c(auto_qmail,"bin","pinq",auto_uido,auto_gidq,0755);
*** qmail-1.03-orig/install.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/install.c Wed May 14 14:33:43 2003
***************
*** 53,58 ****
--- 53,60 ----
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
+ #ifndef __CYGWIN
+ /* mkfifo not supported */
if (fifo_make(fifo,0700) == -1)
if (errno != error_exist)
strerr_die6sys(111,FATAL,"unable to mkfifo ",home,"/",fifo,": ");
***************
*** 60,65 ****
--- 62,68 ----
strerr_die6sys(111,FATAL,"unable to chown ",home,"/",fifo,": ");
if (chmod(fifo,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",fifo,": ");
+ #endif
}
char inbuf[SUBSTDIO_INSIZE];
*** qmail-1.03-orig/lock.h Mon Jun 15 13:53:16 1998
--- qmail-1.03/lock.h Wed May 14 14:36:01 2003
***************
*** 1,8 ****
#ifndef LOCK_H
#define LOCK_H
! extern int lock_ex();
! extern int lock_un();
! extern int lock_exnb();
#endif
--- 1,15 ----
#ifndef LOCK_H
#define LOCK_H
! #ifdef __CYGWIN__
! #define LOCK_SH 0x01
! #define LOCK_EX 0x02
! #define LOCK_NB 0x04
! #define LOCK_UN 0x08
! #endif
!
! extern int lock_ex(int);
! extern int lock_un(int);
! extern int lock_exnb(int);
#endif
*** qmail-1.03-orig/lock_ex.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/lock_ex.c Wed May 14 14:19:36 2003
***************
*** 4,11 ****
#include "hasflock.h"
#include "lock.h"
#ifdef HASFLOCK
! int lock_ex(fd) int fd; { return flock(fd,LOCK_EX); }
#else
! int lock_ex(fd) int fd; { return lockf(fd,1,0); }
#endif
--- 4,42 ----
#include "hasflock.h"
#include "lock.h"
+ #ifdef __CYGWIN__
+ #include <unistd.h>
+ #include <errno.h>
+
+ int fcntl_flock(int fd,int op)
+ {
+ struct flock fl;
+ /* lock applies to entire file */
+ fl.l_whence = fl.l_start = fl.l_len = 0;
+ fl.l_pid = getpid ();/* shouldn't be necessary */
+ switch (op & ~LOCK_NB) {/* translate to fcntl() operation */
+ case LOCK_EX:/* exclusive */
+ fl.l_type = F_WRLCK;
+ break;
+ case LOCK_SH:/* shared */
+ fl.l_type = F_RDLCK;
+ break;
+ case LOCK_UN:/* unlock */
+ fl.l_type = F_UNLCK;
+ break;
+ default:/* default */
+ errno = EINVAL;
+ return -1;
+ }
+ return (fcntl (fd,(op & LOCK_NB) ? F_SETLK : F_SETLKW,&fl) == -1) ? -1
: 0;
+ }
+
+ int flock(int fd,int op)
+ { return fcntl_flock(fd,op); }
+ #endif
+
#ifdef HASFLOCK
! int lock_ex(int fd) { return flock(fd,LOCK_EX); }
#else
! int lock_ex(int fd) { return lockf(fd,1,0); }
#endif
*** qmail-1.03-orig/lock_exnb.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/lock_exnb.c Wed May 14 14:19:42 2003
***************
*** 4,11 ****
#include "hasflock.h"
#include "lock.h"
#ifdef HASFLOCK
! int lock_exnb(fd) int fd; { return flock(fd,LOCK_EX | LOCK_NB); }
#else
! int lock_exnb(fd) int fd; { return lockf(fd,2,0); }
#endif
--- 4,43 ----
#include "hasflock.h"
#include "lock.h"
+ #ifdef __CYGWIN__
+ #include <unistd.h>
+ #include <errno.h>
+
+ int fcntl_nbflock(int fd,int op)
+ {
+ struct flock fl;
+ /* lock applies to entire file */
+ fl.l_whence = fl.l_start = fl.l_len = 0;
+ fl.l_pid = getpid ();/* shouldn't be necessary */
+ switch (op & ~LOCK_NB) {/* translate to fcntl() operation */
+ case LOCK_EX:/* exclusive */
+ fl.l_type = F_WRLCK;
+ break;
+ case LOCK_SH:/* shared */
+ fl.l_type = F_RDLCK;
+ break;
+ case LOCK_UN:/* unlock */
+ fl.l_type = F_UNLCK;
+ break;
+ default:/* default */
+ errno = EINVAL;
+ return -1;
+ }
+ return (fcntl (fd,(op & LOCK_NB) ? F_SETLK : F_SETLKW,&fl) == -1) ? -1
: 0;
+ }
+ #endif
+
#ifdef HASFLOCK
! #ifdef __CYGWIN__
! int lock_exnb(int fd) { return fcntl_nbflock(fd,LOCK_EX | LOCK_NB); }
! #else
! int lock_exnb(int fd) { return flock(fd,LOCK_EX | LOCK_NB); }
! #endif
#else
! int lock_exnb(int fd) { return lockf(fd,2,0); }
#endif
*** qmail-1.03-orig/lock_un.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/lock_un.c Wed May 14 14:19:47 2003
***************
*** 4,11 ****
#include "hasflock.h"
#include "lock.h"
#ifdef HASFLOCK
! int lock_un(fd) int fd; { return flock(fd,LOCK_UN); }
#else
! int lock_un(fd) int fd; { return lockf(fd,0,0); }
#endif
--- 4,43 ----
#include "hasflock.h"
#include "lock.h"
+ #ifdef __CYGWIN__
+ #include <unistd.h>
+ #include <errno.h>
+
+ int fcntl_unflock(int fd,int op)
+ {
+ struct flock fl;
+ /* lock applies to entire file */
+ fl.l_whence = fl.l_start = fl.l_len = 0;
+ fl.l_pid = getpid ();/* shouldn't be necessary */
+ switch (op & ~LOCK_NB) {/* translate to fcntl() operation */
+ case LOCK_EX:/* exclusive */
+ fl.l_type = F_WRLCK;
+ break;
+ case LOCK_SH:/* shared */
+ fl.l_type = F_RDLCK;
+ break;
+ case LOCK_UN:/* unlock */
+ fl.l_type = F_UNLCK;
+ break;
+ default:/* default */
+ errno = EINVAL;
+ return -1;
+ }
+ return (fcntl (fd,(op & LOCK_NB) ? F_SETLK : F_SETLKW,&fl) == -1) ? -1
: 0;
+ }
+ #endif
+
#ifdef HASFLOCK
! #ifdef __CYGWIN__
! int lock_un(int fd) { return fcntl_unflock(fd,LOCK_UN); }
! #else
! int lock_un(int fd) { return flock(fd,LOCK_UN); }
! #endif
#else
! int lock_un(int fd) { return lockf(fd,0,0); }
#endif
*** qmail-1.03-orig/prot.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/prot.c Sun May 11 16:43:04 2003
***************
*** 5,10 ****
--- 5,14 ----
int prot_gid(gid) int gid;
{
+ #ifdef __CYGWIN__
+ /* setgid() not implemented */
+ return(0);
+ #else
#ifdef HASSHORTSETGROUPS
short x[2];
x[0] = gid; x[1] = 73; /* catch errors */
***************
*** 13,21 ****
--- 17,31 ----
if (setgroups(1,&gid) == -1) return -1;
#endif
return setgid(gid); /* _should_ be redundant, but on some systems it
isn't */
+ #endif
}
int prot_uid(uid) int uid;
{
+ #ifdef __CYGWIN__
+ /* setuid() not implemented */
+ return(0);
+ #else
return setuid(uid);
+ #endif
}
*** qmail-1.03-orig/trigger.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/trigger.c Wed May 14 12:13:28 2003
***************
*** 2,23 ****
#include "open.h"
#include "trigger.h"
#include "hasnpbg1.h"
static int fd = -1;
! #ifdef HASNAMEDPIPEBUG1
static int fdw = -1;
#endif
void trigger_set()
{
if (fd != -1)
close(fd);
! #ifdef HASNAMEDPIPEBUG1
if (fdw != -1)
close(fdw);
#endif
fd = open_read("lock/trigger");
! #ifdef HASNAMEDPIPEBUG1
fdw = open_write("lock/trigger");
#endif
}
--- 2,49 ----
#include "open.h"
#include "trigger.h"
#include "hasnpbg1.h"
+ #ifdef __CYGWIN__
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <stdio.h>
+
+ struct sockaddr trigger_sock;
+ int fds = -1, trigger_sock_len;
+ #endif
static int fd = -1;
! #if defined HASNAMEDPIPEBUG1 && !defined __CYGWIN__
static int fdw = -1;
#endif
void trigger_set()
{
+ #ifdef __CYGWIN__
+ unlink("lock/trigger");
+ fds = socket(AF_UNIX,SOCK_STREAM,0);
+ if (fds >= 0) {
+ trigger_sock.sa_family = AF_UNIX;
+ strcpy(trigger_sock.sa_data,"lock/trigger");
+ trigger_sock_len = strlen(trigger_sock.sa_data) +
+ sizeof(trigger_sock.sa_family);
+ if (bind(fds,&trigger_sock,trigger_sock_len) >= 0)
+ if (listen(fds,1) >= 0) {
+ #endif
if (fd != -1)
close(fd);
! #if defined HASNAMEDPIPEBUG1 && !defined __CYGWIN__
if (fdw != -1)
close(fdw);
#endif
+ #ifndef __CYGWIN__
fd = open_read("lock/trigger");
! #else
! if ((fd = accept(fds,&trigger_sock,&trigger_sock_len)) >= 0)
! close(fds);
! }
! }
! #endif
! #if defined HASNAMEDPIPEBUG1 && !defined __CYGWIN__
fdw = open_write("lock/trigger");
#endif
}
*** qmail-1.03-orig/triggerpull.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/triggerpull.c Wed May 14 11:48:52 2003
***************
*** 1,16 ****
#include "ndelay.h"
#include "open.h"
#include "triggerpull.h"
void triggerpull()
{
int fd;
!
fd = open_write("lock/trigger");
if (fd >= 0)
{
ndelay_on(fd);
write(fd,"",1); /* if it fails, bummer */
close(fd);
}
}
--- 1,36 ----
#include "ndelay.h"
#include "open.h"
#include "triggerpull.h"
+ #ifdef __CYGWIN__
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/stdio.h>
+ #endif
void triggerpull()
{
int fd;
! #ifndef __CYGWIN__
fd = open_write("lock/trigger");
+ #else
+ int trigger_sock_len;
+ struct sockaddr trigger_sock;
+
+ fd = socket(AF_UNIX,SOCK_STREAM,0);
+ if (fd >= 0) {
+ trigger_sock.sa_family = AF_UNIX;
+ strcpy(trigger_sock.sa_data,"lock/trigger");
+ trigger_sock_len = strlen(trigger_sock.sa_data) +
+ sizeof(trigger_sock.sa_family);
+ if (connect(fd,&trigger_sock,trigger_sock_len) >= 0)
+ #endif
if (fd >= 0)
{
ndelay_on(fd);
write(fd,"",1); /* if it fails, bummer */
close(fd);
}
+ #ifdef __CYGWIN__
+ }
+ #endif
}
*** qmail-1.03-orig/tryflock.c Mon Jun 15 13:53:16 1998
--- qmail-1.03/tryflock.c Wed May 14 14:19:30 2003
***************
*** 2,8 ****
#include <sys/file.h>
#include <fcntl.h>
! void main()
{
flock(0,LOCK_EX | LOCK_UN | LOCK_NB);
}
--- 2,40 ----
#include <sys/file.h>
#include <fcntl.h>
! #ifdef __CYGWIN__
! #include "lock.h"
! #include <unistd.h>
! #include <errno.h>
!
! int fcntl_flock(int fd,int op)
! {
! struct flock fl;
! /* lock applies to entire file */
! fl.l_whence = fl.l_start = fl.l_len = 0;
! fl.l_pid = getpid ();/* shouldn't be necessary */
! switch (op & ~LOCK_NB) {/* translate to fcntl() operation */
! case LOCK_EX:/* exclusive */
! fl.l_type = F_WRLCK;
! break;
! case LOCK_SH:/* shared */
! fl.l_type = F_RDLCK;
! break;
! case LOCK_UN:/* unlock */
! fl.l_type = F_UNLCK;
! break;
! default:/* default */
! errno = EINVAL;
! return -1;
! }
! return (fcntl (fd,(op & LOCK_NB) ? F_SETLK : F_SETLKW,&fl) == -1) ? -1
: 0;
! }
!
! int flock(int fd,int op)
! { return fcntl_flock(fd,op); }
! #endif
!
! main()
{
flock(0,LOCK_EX | LOCK_UN | LOCK_NB);
}
======cut======
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/