* samba/configure.in: Remove more useless tests.
* samba/tests/crypttest.c: Remove. * samba/tests/fcntl_lock.c: Likewise. * samba/tests/shared_mmap.c: Likewise. * samba/tests/sysv_ipc.c: Likewise. * samba/samba-files: Likewise. * samba/smbadduser: Likewise. * Make-mc.in: Adjust for the above. * samba/include/includes.h: Removed definitions related to the above tests.
Этот коммит содержится в:
родитель
90096c49b9
Коммит
53a4e96313
@ -1,5 +1,16 @@
|
||||
2001-02-09 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* samba/configure.in: Remove more useless tests.
|
||||
* samba/tests/crypttest.c: Remove.
|
||||
* samba/tests/fcntl_lock.c: Likewise.
|
||||
* samba/tests/shared_mmap.c: Likewise.
|
||||
* samba/tests/sysv_ipc.c: Likewise.
|
||||
* samba/samba-files: Likewise.
|
||||
* samba/smbadduser: Likewise.
|
||||
* Make-mc.in: Adjust for the above.
|
||||
* samba/include/includes.h: Removed definitions related to the
|
||||
above tests.
|
||||
|
||||
* Make-mc.in: Eliminate ubiqx.
|
||||
* samba/Makefile.in: Likewise. Remove some unused variables.
|
||||
* samba/include/includes.h: Eliminate dependency on ubiqx.
|
||||
|
@ -67,9 +67,7 @@ SAMBA_DIST_TOPLEVEL = \
|
||||
configure.in \
|
||||
configure \
|
||||
internals.doc \
|
||||
parsing.doc \
|
||||
samba-files \
|
||||
smbadduser
|
||||
parsing.doc
|
||||
|
||||
SAMBA_DIST_INCLUDE = \
|
||||
byteorder.h \
|
||||
@ -137,13 +135,9 @@ SAMBA_DIST_PARAM = \
|
||||
|
||||
SAMBA_DIST_TESTS = \
|
||||
README \
|
||||
crypttest.c \
|
||||
fcntl_lock.c \
|
||||
ftruncate.c \
|
||||
getgroups.c \
|
||||
shared_mmap.c \
|
||||
summary.c \
|
||||
sysv_ipc.c \
|
||||
trivial.c
|
||||
|
||||
NONETFILES = \
|
||||
|
@ -611,61 +611,6 @@ if test x"$samba_cv_HAVE_NETMASK_AIX" = x"yes"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for shared mmap],samba_cv_HAVE_SHARED_MMAP,[
|
||||
AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
|
||||
samba_cv_HAVE_SHARED_MMAP=yes,samba_cv_HAVE_SHARED_MMAP=no,samba_cv_HAVE_SHARED_MMAP=cross)])
|
||||
if test x"$samba_cv_HAVE_SHARED_MMAP" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SHARED_MMAP)
|
||||
AC_DEFINE(HAVE_MMAP)
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
|
||||
AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
|
||||
samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
|
||||
if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
|
||||
AC_DEFINE(HAVE_FCNTL_LOCK)
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
|
||||
AC_TRY_RUN([
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
main() { struct flock64 fl64;
|
||||
#if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
|
||||
exit(0);
|
||||
#else
|
||||
exit(1);
|
||||
#endif
|
||||
}],
|
||||
samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
|
||||
if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
|
||||
AC_DEFINE(HAVE_STRUCT_FLOCK64)
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for sysv ipc],samba_cv_HAVE_SYSV_IPC,[
|
||||
AC_TRY_RUN([#include "${srcdir-.}/tests/sysv_ipc.c"],
|
||||
samba_cv_HAVE_SYSV_IPC=yes,samba_cv_HAVE_SYSV_IPC=no,samba_cv_HAVE_SYSV_IPC=cross)])
|
||||
if test x"$samba_cv_HAVE_SYSV_IPC" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SYSV_IPC)
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
|
||||
AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
|
||||
samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
|
||||
if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
|
||||
AC_DEFINE(HAVE_TRUNCATED_SALT)
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
|
||||
AC_TRY_COMPILE([#include <sys/acl.h>
|
||||
|
@ -55,27 +55,6 @@
|
||||
#endif
|
||||
#endif /* RELIANTUNIX */
|
||||
|
||||
#ifdef HAVE_SYSV_IPC
|
||||
#define USE_SYSV_IPC
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHARED_MMAP
|
||||
#define USE_SHARED_MMAP
|
||||
#endif
|
||||
|
||||
|
||||
/* if we have both SYSV IPC and shared mmap then we need to choose. For most
|
||||
systems it is much faster to use SYSV IPC, but under Linux it is
|
||||
about 5 times faster to use fcntl, so for Linux systems we force
|
||||
fcntl based locking */
|
||||
#if (defined(USE_SYSV_IPC) && defined(USE_SHARED_MMAP))
|
||||
# ifdef LINUX
|
||||
# undef USE_SYSV_IPC
|
||||
# else
|
||||
# undef USE_SHARED_MMAP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
|
@ -1,102 +0,0 @@
|
||||
./lib/snprintf.c
|
||||
./lib/smbrun.c
|
||||
./lib/crc32.c
|
||||
./lib/ufc.c
|
||||
./lib/fault.c
|
||||
./lib/charcnv.c
|
||||
./lib/access.c
|
||||
./lib/replace.c
|
||||
./lib/netatalk.c
|
||||
./lib/util_sec.c
|
||||
./lib/util_sid.c
|
||||
./lib/bitmap.c
|
||||
./lib/pidfile.c
|
||||
./passdb/passgrp.c
|
||||
./passdb/passdb.c
|
||||
./passdb/ldap.c
|
||||
./passdb/smbpass.c
|
||||
./passdb/nispass.c
|
||||
./passdb/smbpasschange.c
|
||||
./passdb/smbpassgroup.c
|
||||
./passdb/pass_check.c
|
||||
./passdb/smbpassfile.c
|
||||
./locking/locking_slow.c
|
||||
./locking/shmem_sysv.c
|
||||
./locking/locking_shm.c
|
||||
./locking/shmem.c
|
||||
./locking/locking.c
|
||||
./tests/crypttest.c
|
||||
./tests/sysv_ipc.c
|
||||
./tests/ftruncate.c
|
||||
./tests/summary.c
|
||||
./tests/ftruncroot.c
|
||||
./tests/fcntl_lock.c
|
||||
./tests/trapdoor.c
|
||||
./tests/getgroups.c
|
||||
./tests/shared_mmap.c
|
||||
./tests/trivial.c
|
||||
./ubiqx/ubi_Cache.c
|
||||
./ubiqx/ubi_SplayTree.c
|
||||
./ubiqx/debugparse.c
|
||||
./ubiqx/ubi_dLinkList.c
|
||||
./ubiqx/ubi_sLinkList.c
|
||||
./ubiqx/ubi_BinTree.c
|
||||
./utils/torture.c
|
||||
./utils/nbio.c
|
||||
./utils/smbrun.c
|
||||
./utils/debug2html.c
|
||||
./utils/make_smbcodepage.c
|
||||
./utils/testprns.c
|
||||
./utils/status.c
|
||||
./utils/nmblookup.c
|
||||
./utils/testparm.c
|
||||
./utils/make_printerdef.c
|
||||
./utils/rpctorture.c
|
||||
./utils/smbfilter.c
|
||||
./utils/smbpasswd.c
|
||||
./rpc_parse/parse_net.c
|
||||
./rpc_parse/parse_lsa.c
|
||||
./rpc_parse/parse_samr.c
|
||||
./rpc_parse/parse_wks.c
|
||||
./rpc_parse/parse_srv.c
|
||||
./rpc_parse/parse_sec.c
|
||||
./rpc_parse/parse_rpc.c
|
||||
./rpc_parse/parse_reg.c
|
||||
./rpc_parse/parse_misc.c
|
||||
./rpc_parse/parse_prs.c
|
||||
./libsmb/passchange.c
|
||||
./libsmb/credentials.c
|
||||
./rpc_client/cli_netlogon.c
|
||||
./rpc_client/cli_login.c
|
||||
./rpc_client/ntclienttrust.c
|
||||
./rpc_client/cli_reg.c
|
||||
./rpc_client/cli_pipe.c
|
||||
./rpc_client/cli_srvsvc.c
|
||||
./rpc_client/cli_wkssvc.c
|
||||
./rpc_client/cli_samr.c
|
||||
./rpc_client/cli_lsarpc.c
|
||||
./rpcclient/cmd_netlogon.c
|
||||
./rpcclient/rpcclient.c
|
||||
./rpcclient/cmd_reg.c
|
||||
./rpcclient/cmd_srvsvc.c
|
||||
./rpcclient/cmd_wkssvc.c
|
||||
./rpcclient/cmd_lsarpc.c
|
||||
./rpcclient/display.c
|
||||
./rpcclient/cmd_samr.c
|
||||
./client/clitar.c
|
||||
./client/client.c
|
||||
./client/clientutil.c
|
||||
./client/smbmount.c
|
||||
./client/smbumount.c
|
||||
./client/smbmnt.c
|
||||
./printing/pcap.c
|
||||
./printing/print_svid.c
|
||||
./printing/printing.c
|
||||
./smbwrapper/realcalls.c
|
||||
./smbwrapper/shared.c
|
||||
./smbwrapper/smbsh.c
|
||||
./smbwrapper/wrapped.c
|
||||
./smbwrapper/smbw_dir.c
|
||||
./smbwrapper/smbw_stat.c
|
||||
./smbwrapper/smbw.c
|
||||
./smbwrapper/init.c
|
@ -1,73 +0,0 @@
|
||||
#!/bin/csh
|
||||
#
|
||||
# smbadduser - Written by Mike Zakharoff
|
||||
#
|
||||
unalias *
|
||||
set path = ($path /usr/local/samba/bin)
|
||||
|
||||
set smbpasswd = /usr/local/samba/private/smbpasswd
|
||||
set user_map = /usr/local/samba/lib/users.map
|
||||
#
|
||||
# Set to site specific passwd command
|
||||
#
|
||||
#set passwd = "cat /etc/passwd"
|
||||
#set passwd = "niscat passwd.org_dir"
|
||||
set passwd = "ypcat passwd"
|
||||
|
||||
set line = "----------------------------------------------------------"
|
||||
if ($#argv == 0) then
|
||||
echo $line
|
||||
echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
|
||||
echo ""
|
||||
echo " 1) Updates $smbpasswd"
|
||||
echo " 2) Updates $user_map"
|
||||
echo " 3) Executes smbpasswd for each new user"
|
||||
echo ""
|
||||
echo "smbadduser unixid:ntid unixid:ntid ..."
|
||||
echo ""
|
||||
echo "Example: smbadduser zak:zakharoffm johns:smithj"
|
||||
echo $line
|
||||
exit 1
|
||||
endif
|
||||
|
||||
touch $smbpasswd $user_map
|
||||
set new = ()
|
||||
foreach one ($argv)
|
||||
echo $one | grep ':' >& /dev/null
|
||||
if ($status != 0) then
|
||||
echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
|
||||
continue
|
||||
endif
|
||||
set unix = `echo $one | awk -F: '{print $1}'`
|
||||
set ntid = `echo $one | awk -F: '{print $2}'`
|
||||
|
||||
set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
|
||||
if ($#usr != 1) then
|
||||
echo "ERROR: $unix Not in passwd database SKIPPING..."
|
||||
continue
|
||||
endif
|
||||
set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
|
||||
if ($#tmp != 0) then
|
||||
echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
|
||||
continue
|
||||
endif
|
||||
|
||||
echo "Adding: $unix to $smbpasswd"
|
||||
eval $passwd | \
|
||||
awk -F: '$1==USR { \
|
||||
printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }' USR=$unix >> $smbpasswd
|
||||
if ($unix != $ntid) then
|
||||
echo "Adding: {$unix = $ntid} to $user_map"
|
||||
echo "$unix = $ntid" >> $user_map
|
||||
endif
|
||||
set new = ($new $unix)
|
||||
end
|
||||
|
||||
#
|
||||
# Enter password for new users
|
||||
#
|
||||
foreach one ($new)
|
||||
echo $line
|
||||
echo "ENTER password for $one"
|
||||
smbpasswd $one
|
||||
end
|
@ -1,74 +0,0 @@
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
main()
|
||||
{
|
||||
char passwd[9];
|
||||
char salt[9];
|
||||
char c_out1[256];
|
||||
char c_out2[256];
|
||||
|
||||
char expected_out[14];
|
||||
|
||||
strcpy(expected_out, "12yJ.Of/NQ.Pk");
|
||||
strcpy(passwd, "12345678");
|
||||
strcpy(salt, "12345678");
|
||||
|
||||
strcpy(c_out1, crypt(passwd, salt));
|
||||
salt[2] = '\0';
|
||||
strcpy(c_out2, crypt(passwd, salt));
|
||||
|
||||
/*
|
||||
* If the non-trucated salt fails but the
|
||||
* truncated salt succeeds then exit 1.
|
||||
*/
|
||||
|
||||
if((strcmp(c_out1, expected_out) != 0) &&
|
||||
(strcmp(c_out2, expected_out) == 0))
|
||||
exit(1);
|
||||
|
||||
#ifdef HAVE_BIGCRYPT
|
||||
/*
|
||||
* Try the same with bigcrypt...
|
||||
*/
|
||||
|
||||
{
|
||||
char big_passwd[17];
|
||||
char big_salt[17];
|
||||
char big_c_out1[256];
|
||||
char big_c_out2[256];
|
||||
char big_expected_out[27];
|
||||
|
||||
strcpy(big_passwd, "1234567812345678");
|
||||
strcpy(big_salt, "1234567812345678");
|
||||
strcpy(big_expected_out, "12yJ.Of/NQ.PklfyCuHi/rwM");
|
||||
|
||||
strcpy(big_c_out1, bigcrypt(big_passwd, big_salt));
|
||||
big_salt[2] = '\0';
|
||||
strcpy(big_c_out2, bigcrypt(big_passwd, big_salt));
|
||||
|
||||
/*
|
||||
* If the non-trucated salt fails but the
|
||||
* truncated salt succeeds then exit 1.
|
||||
*/
|
||||
|
||||
if((strcmp(big_c_out1, big_expected_out) != 0) &&
|
||||
(strcmp(big_c_out2, big_expected_out) == 0))
|
||||
exit(1);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
exit(0);
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* test whether fcntl locking works on this system */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
static int sys_waitpid(pid_t pid,int *status,int options)
|
||||
{
|
||||
#ifdef HAVE_WAITPID
|
||||
return waitpid(pid,status,options);
|
||||
#else /* USE_WAITPID */
|
||||
return wait4(pid, status, options, NULL);
|
||||
#endif /* USE_WAITPID */
|
||||
}
|
||||
|
||||
#define DATA "conftest.fcntl"
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
/* lock a byte range in a open file */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct flock lock;
|
||||
int fd, pid, ret, status=1;
|
||||
|
||||
if (!(pid=fork())) {
|
||||
sleep(2);
|
||||
fd = open(DATA, O_RDONLY);
|
||||
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
lock.l_type = F_WRLCK;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 4;
|
||||
lock.l_pid = getpid();
|
||||
|
||||
lock.l_type = F_WRLCK;
|
||||
|
||||
/* check if a lock applies */
|
||||
ret = fcntl(fd,F_GETLK,&lock);
|
||||
|
||||
if ((ret == -1) ||
|
||||
(lock.l_type == F_UNLCK)) {
|
||||
exit(1);
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
|
||||
|
||||
lock.l_type = F_WRLCK;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 4;
|
||||
lock.l_pid = getpid();
|
||||
|
||||
/* set a 4 byte write lock */
|
||||
fcntl(fd,F_SETLK,&lock);
|
||||
|
||||
sys_waitpid(pid, &status, 0);
|
||||
|
||||
unlink(DATA);
|
||||
|
||||
exit(status);
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/* this tests whether we can use a shared writeable mmap on a file -
|
||||
as needed for the mmap varient of FAST_SHARE_MODES */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define DATA "conftest.mmap"
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
main()
|
||||
{
|
||||
int *buf;
|
||||
int i, pid;
|
||||
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
|
||||
int count=7;
|
||||
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
for (i=0;i<10000;i++) {
|
||||
write(fd,&i,sizeof(i));
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
if (fork() == 0) {
|
||||
fd = open(DATA,O_RDWR);
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
buf = (int *)mmap(NULL, 10000*sizeof(int),
|
||||
(PROT_READ | PROT_WRITE),
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, 0);
|
||||
|
||||
while (count-- && buf[9124] != 55732) sleep(1);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
|
||||
buf[1763] = 7268;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fd = open(DATA,O_RDWR);
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
buf = (int *)mmap(NULL, 10000*sizeof(int),
|
||||
(PROT_READ | PROT_WRITE),
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, 0);
|
||||
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
buf[9124] = 55732;
|
||||
|
||||
while (count-- && buf[1763] != 7268) sleep(1);
|
||||
|
||||
unlink(DATA);
|
||||
|
||||
if (count > 0) exit(0);
|
||||
exit(1);
|
||||
}
|
@ -2,15 +2,6 @@
|
||||
|
||||
main()
|
||||
{
|
||||
#if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64))
|
||||
printf("ERROR: No locking available. Running Samba would be unsafe\n");
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
#if !(defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP))
|
||||
printf("WARNING: no shared memory. Running with slow locking code\n");
|
||||
#endif
|
||||
|
||||
#if !(defined(HAVE_NETMASK_IFCONF) || defined(HAVE_NETMASK_IFREQ) || defined(HAVE_NETMASK_AIX))
|
||||
printf("WARNING: No automated netmask determination - use an interfaces line\n");
|
||||
#endif
|
||||
|
@ -1,88 +0,0 @@
|
||||
/* this tests whether we can use a sysv shared memory segment
|
||||
as needed for the sysv varient of FAST_SHARE_MODES */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
#define KEY 0x963796
|
||||
#define SEMKEY 0x963797
|
||||
#define SIZE (32*1024)
|
||||
|
||||
#ifndef HAVE_UNION_SEMUN
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
int id, sem_id;
|
||||
int *buf;
|
||||
int count=7;
|
||||
union semun su;
|
||||
|
||||
#ifdef LINUX
|
||||
if (sizeof(struct shmid_ds) == 52) {
|
||||
printf("WARNING: You probably have a broken set of glibc2 include files - disabling sysv shared memory\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
sem_id = semget(SEMKEY, 1, IPC_CREAT|IPC_EXCL|0600);
|
||||
|
||||
if (sem_id == -1) exit(1);
|
||||
|
||||
su.val = 1;
|
||||
semctl(sem_id, 0, IPC_RMID, su);
|
||||
|
||||
id = shmget(KEY, 0, 0);
|
||||
if (id != -1) {
|
||||
if (shmctl(id, IPC_RMID, 0) != 0) exit(1);
|
||||
}
|
||||
|
||||
if (fork() == 0) {
|
||||
/* uggh - need locking */
|
||||
sleep(2);
|
||||
|
||||
/* get an existing area */
|
||||
id = shmget(KEY, 0, 0);
|
||||
if (id == -1) exit(1);
|
||||
|
||||
buf = (int *)shmat(id, 0, 0);
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
|
||||
while (count-- && buf[6124] != 55732) sleep(1);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
|
||||
buf[1763] = 7268;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
id = shmget(KEY, SIZE, IPC_CREAT | IPC_EXCL | 0600);
|
||||
if (id == -1) exit(1);
|
||||
|
||||
buf = (int *)shmat(id, 0, 0);
|
||||
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
buf[6124] = 55732;
|
||||
|
||||
while (count-- && buf[1763] != 7268) sleep(1);
|
||||
|
||||
shmctl(id, IPC_RMID, 0);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
exit(0);
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user