summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-05-02 02:23:41 +0000
committerJeremy Allison <jra@samba.org>2000-05-02 02:23:41 +0000
commit148628b616b5c29ba6340d65fc3ddbcabba6e67a (patch)
treef8482fb2dcfa68baeb38a38e2c73ee105abb00a2 /source
parent3b25f7368be3877e9ad27498bc9451ec88d4b07f (diff)
downloadsamba-148628b616b5c29ba6340d65fc3ddbcabba6e67a.tar.gz
samba-148628b616b5c29ba6340d65fc3ddbcabba6e67a.tar.xz
samba-148628b616b5c29ba6340d65fc3ddbcabba6e67a.zip
Added sys_fork() and sys_getpid() functions to stop the overhead
of doing a system call every time we want to just get our pid. Jeremy.
Diffstat (limited to 'source')
-rw-r--r--source/auth/pass_check.c6
-rw-r--r--source/client/client.c8
-rw-r--r--source/client/smbmount.c4
-rw-r--r--source/include/proto.h2
-rw-r--r--source/lib/debug.c2
-rw-r--r--source/lib/fault.c2
-rw-r--r--source/lib/genrand.c2
-rw-r--r--source/lib/ms_fnmatch.c2
-rw-r--r--source/lib/pidfile.c2
-rw-r--r--source/lib/smbrun.c2
-rw-r--r--source/lib/substitute.c2
-rw-r--r--source/lib/system.c32
-rw-r--r--source/lib/util.c6
-rw-r--r--source/libsmb/clientgen.c2
-rw-r--r--source/libsmb/namequery.c2
-rw-r--r--source/locking/locking.c16
-rw-r--r--source/nmbd/asyncdns.c2
-rw-r--r--source/nmbd/nmbd.c2
-rw-r--r--source/nmbd/nmbd_packets.c2
-rw-r--r--source/nmbd/nmbd_synclists.c2
-rw-r--r--source/nmbd/nmbd_winsserver.c4
-rw-r--r--source/passdb/pass_check.c6
-rw-r--r--source/passdb/smbpass.c2
-rw-r--r--source/printing/printing.c4
-rw-r--r--source/rpc_server/srv_lsa_hnd.c2
-rw-r--r--source/rpc_server/srv_pipe_hnd.c4
-rw-r--r--source/rpc_server/srv_spoolss_nt.c2
-rw-r--r--source/smbd/chgpasswd.c2
-rw-r--r--source/smbd/connection.c6
-rw-r--r--source/smbd/fileio.c2
-rw-r--r--source/smbd/files.c2
-rw-r--r--source/smbd/negprot.c6
-rw-r--r--source/smbd/open.c4
-rw-r--r--source/smbd/oplock.c6
-rw-r--r--source/smbd/password.c4
-rw-r--r--source/smbd/process.c2
-rw-r--r--source/smbd/server.c2
-rw-r--r--source/smbd/service.c2
38 files changed, 98 insertions, 64 deletions
diff --git a/source/auth/pass_check.c b/source/auth/pass_check.c
index c3e56697476..0496ed9961f 100644
--- a/source/auth/pass_check.c
+++ b/source/auth/pass_check.c
@@ -439,7 +439,7 @@ static BOOL dfs_auth(char *user, char *password)
}
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
- user, getpid()));
+ user, sys_getpid()));
DEBUG(3, ("DCE principal: %s\n"
" uid: %d\n"
@@ -487,7 +487,7 @@ void dfs_unlogin(void)
dce_error_inq_text(err, dce_errstr, &err2);
DEBUG(0,
("DCE purge login context failed for server instance %d: %s\n",
- getpid(), dce_errstr));
+ sys_getpid(), dce_errstr));
}
}
#endif
@@ -595,7 +595,7 @@ static BOOL krb4_auth(char *user, char *password)
}
(void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
- (int)getpid());
+ (int)sys_getpid());
krb_set_tkt_string(tkfile);
if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
diff --git a/source/client/client.c b/source/client/client.c
index ade1436871c..7431b2704e5 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -849,7 +849,7 @@ static void cmd_more(void)
fstrcat(rname,"\\");
slprintf(tmpname,
sizeof(fstring)-1,
- "%s/smbmore.%d",tmpdir(),(int)getpid());
+ "%s/smbmore.%d",tmpdir(),(int)sys_getpid());
fstrcpy(lname,tmpname);
if (!next_token(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
@@ -1159,7 +1159,7 @@ static void cmd_mput(void)
FILE *f;
slprintf(tmpname,sizeof(pstring)-1,
- "%s/ls.smb.%d",tmpdir(),(int)getpid());
+ "%s/ls.smb.%d",tmpdir(),(int)sys_getpid());
if (recurse)
slprintf(cmd,sizeof(pstring)-1,
"find . -name \"%s\" -print > %s",p,tmpname);
@@ -1269,11 +1269,11 @@ static void cmd_print(void)
pstrcpy(rname,lname);
p = strrchr(rname,'/');
if (p) {
- slprintf(rname, sizeof(rname)-1, "%s-%d", p+1, (int)getpid());
+ slprintf(rname, sizeof(rname)-1, "%s-%d", p+1, (int)sys_getpid());
}
if (strequal(lname,"-")) {
- slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)getpid());
+ slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)sys_getpid());
}
do_put(rname, lname);
diff --git a/source/client/smbmount.c b/source/client/smbmount.c
index 18af824c1fd..ec3f32bd366 100644
--- a/source/client/smbmount.c
+++ b/source/client/smbmount.c
@@ -72,7 +72,7 @@ static void daemonize(void)
signal( SIGTERM, exit_parent );
- if ((child_pid = fork()) < 0) {
+ if ((child_pid = sys_fork()) < 0) {
fprintf(stderr,"could not fork\n");
}
@@ -437,7 +437,7 @@ static void init_mount(void)
args[i++] = xstrdup(tmp);
}
- if (fork() == 0) {
+ if (sys_fork() == 0) {
if (file_exist(BINDIR "/smbmnt", NULL)) {
execv(BINDIR "/smbmnt", args);
fprintf(stderr,"execv of %s failed. Error was %s.", BINDIR "/smbmnt", strerror(errno));
diff --git a/source/include/proto.h b/source/include/proto.h
index 6e22fd171f1..d418ac42681 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -246,6 +246,8 @@ DIR *wsys_opendir(const smb_ucs2_t *wfname);
smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
int wsys_chroot(const smb_ucs2_t *wfname);
+pid_t sys_fork(void);
+pid_t sys_getpid(void);
int sys_popen(const char *command);
int sys_pclose(int fd);
diff --git a/source/lib/debug.c b/source/lib/debug.c
index ed27b93cfd0..675c2d8cfcb 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -580,7 +580,7 @@ BOOL dbghdr( int level, char *file, char *func, int line )
header_str[0] = '\0';
if( lp_debug_pid())
- slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)getpid());
+ slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)sys_getpid());
if( lp_debug_uid()) {
size_t hs_len = strlen(header_str);
diff --git a/source/lib/fault.c b/source/lib/fault.c
index 6effaf7d7c6..29272f19280 100644
--- a/source/lib/fault.c
+++ b/source/lib/fault.c
@@ -38,7 +38,7 @@ static void fault_report(int sig)
counter++;
DEBUG(0,("===============================================================\n"));
- DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION));
+ DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),VERSION));
DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n"));
DEBUG(0,("===============================================================\n"));
diff --git a/source/lib/genrand.c b/source/lib/genrand.c
index a9698d4cd1b..102eec63009 100644
--- a/source/lib/genrand.c
+++ b/source/lib/genrand.c
@@ -163,7 +163,7 @@ static uint32 do_reseed(unsigned char *md4_outbuf)
* Finally add the counter, time of day, and pid.
*/
GetTimeOfDay(&tval);
- mypid = getpid();
+ mypid = sys_getpid();
v1 = (counter++) + mypid + tval.tv_sec;
v2 = (counter++) * mypid + tval.tv_usec;
diff --git a/source/lib/ms_fnmatch.c b/source/lib/ms_fnmatch.c
index ee9b1cf985e..364fd6f347a 100644
--- a/source/lib/ms_fnmatch.c
+++ b/source/lib/ms_fnmatch.c
@@ -36,6 +36,8 @@
matching routine!
NOTE: this matches only filenames with no directory component
+
+ Returns 0 on match, -1 on fail.
*/
int ms_fnmatch(char *pattern, char *string)
{
diff --git a/source/lib/pidfile.c b/source/lib/pidfile.c
index 726e8c1f21a..a6dc327fd7a 100644
--- a/source/lib/pidfile.c
+++ b/source/lib/pidfile.c
@@ -101,7 +101,7 @@ void pidfile_create(char *name)
}
memset(buf, 0, sizeof(buf));
- slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) getpid());
+ slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
DEBUG(0,("ERROR: can't write to file %s: %s\n",
pidFile, strerror(errno)));
diff --git a/source/lib/smbrun.c b/source/lib/smbrun.c
index 8d666980b38..81dfc10dfb1 100644
--- a/source/lib/smbrun.c
+++ b/source/lib/smbrun.c
@@ -124,7 +124,7 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
CatchChildLeaveStatus();
- if ((pid=fork()) < 0) {
+ if ((pid=sys_fork()) < 0) {
DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
CatchChild();
return errno;
diff --git a/source/lib/substitute.c b/source/lib/substitute.c
index c43c133d6ad..2a575f0c382 100644
--- a/source/lib/substitute.c
+++ b/source/lib/substitute.c
@@ -176,7 +176,7 @@ void standard_sub_basic(char *str)
case 'T' : string_sub(p,"%T", timestring(False),l); break;
case 'a' : string_sub(p,"%a", remote_arch,l); break;
case 'd' :
- slprintf(pidstr,sizeof(pidstr), "%d",(int)getpid());
+ slprintf(pidstr,sizeof(pidstr), "%d",(int)sys_getpid());
string_sub(p,"%d", pidstr,l);
break;
case 'h' : string_sub(p,"%h", myhostname(),l); break;
diff --git a/source/lib/system.c b/source/lib/system.c
index 539f21d49c1..80a968b634c 100644
--- a/source/lib/system.c
+++ b/source/lib/system.c
@@ -933,10 +933,40 @@ static char **extract_args(const char *command)
}
/**************************************************************************
+ Wrapper for fork. Ensures that mypid is reset. Used so we can write
+ a sys_getpid() that only does a system call *once*.
+****************************************************************************/
+
+static pid_t mypid = (pid_t)-1;
+
+pid_t sys_fork(void)
+{
+ pid_t forkret = fork();
+
+ if (forkret == (pid_t)0) /* Child - reset mypid so sys_getpid does a system call. */
+ mypid = (pid_t) -1;
+
+ return forkret;
+}
+
+/**************************************************************************
+ Wrapper for getpid. Ensures we only do a system call *once*.
+****************************************************************************/
+
+pid_t sys_getpid(void)
+{
+ if (mypid == (pid_t)-1)
+ mypid = getpid();
+
+ return mypid;
+}
+
+/**************************************************************************
Wrapper for popen. Safer as it doesn't search a path.
Modified from the glibc sources.
modified by tridge to return a file descriptor. We must kick our FILE* habit
****************************************************************************/
+
typedef struct _popen_list
{
int fd;
@@ -974,7 +1004,7 @@ int sys_popen(const char *command)
if(!(argl = extract_args(command)))
goto err_exit;
- entry->child_pid = fork();
+ entry->child_pid = sys_fork();
if (entry->child_pid == -1) {
goto err_exit;
diff --git a/source/lib/util.c b/source/lib/util.c
index 955e1df080a..8ac9223f2eb 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -741,7 +741,7 @@ become a daemon, discarding the controlling terminal
****************************************************************************/
void become_daemon(void)
{
- if (fork()) {
+ if (sys_fork()) {
_exit(0);
}
@@ -1584,7 +1584,7 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
if ((ret != -1) &&
(lock.l_type != F_UNLCK) &&
(lock.l_pid != 0) &&
- (lock.l_pid != getpid()))
+ (lock.l_pid != sys_getpid()))
{
DEBUG(3,("fd %d is locked by pid %d\n",fd,(int)lock.l_pid));
return(True);
@@ -2110,7 +2110,7 @@ int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
char pidstr[10];
pstring cmd = "/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'";
- slprintf(pidstr, sizeof(pidstr), "%d", getpid());
+ slprintf(pidstr, sizeof(pidstr), "%d", sys_getpid());
pstring_sub(cmd, "%d", pidstr);
if (!fn) {
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
index a3a2483bd55..32564aaf825 100644
--- a/source/libsmb/clientgen.c
+++ b/source/libsmb/clientgen.c
@@ -172,7 +172,7 @@ struct cli_state *cli_initialise(struct cli_state *cli)
cli->port = 0;
cli->fd = -1;
cli->cnum = -1;
- cli->pid = (uint16)getpid();
+ cli->pid = (uint16)sys_getpid();
cli->mid = 1;
cli->vuid = UID_FIELD_INVALID;
cli->protocol = PROTOCOL_NT1;
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index 500a2ff94f9..0db1e367dc3 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -35,7 +35,7 @@ static int generate_trn_id(void)
static int trn_id;
if (trn_id == 0) {
- srandom(getpid());
+ srandom(sys_getpid());
}
trn_id = random();
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 75198d63033..47ae917f9af 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -69,7 +69,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn,
return(False);
ret = !brl_locktest(fsp->dev, fsp->inode,
- global_smbpid, getpid(), conn->cnum,
+ global_smbpid, sys_getpid(), conn->cnum,
offset, count, lock_type);
/*
@@ -107,7 +107,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn,
if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) {
ok = brl_lock(fsp->dev, fsp->inode, fsp->fnum,
- global_smbpid, getpid(), conn->cnum,
+ global_smbpid, sys_getpid(), conn->cnum,
offset, count,
lock_type);
@@ -127,7 +127,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn,
* lock entry.
*/
(void)brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
- global_smbpid, getpid(), conn->cnum,
+ global_smbpid, sys_getpid(), conn->cnum,
offset, count);
}
}
@@ -170,7 +170,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn,
*/
ok = brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
- global_smbpid, getpid(), conn->cnum, offset, count);
+ global_smbpid, sys_getpid(), conn->cnum, offset, count);
if (!ok) {
DEBUG(10,("do_unlock: returning ERRlock.\n" ));
@@ -193,7 +193,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn,
void locking_close_file(files_struct *fsp)
{
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
if (!lp_locking(SNUM(fsp->conn)))
return;
@@ -337,7 +337,7 @@ void del_share_mode(files_struct *fsp)
struct locking_data *data;
int i, del_count=0;
share_mode_entry *shares;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
/* read in the existing share modes */
dbuf = tdb_fetch(tdb, locking_key_fsp(fsp));
@@ -380,7 +380,7 @@ fill a share mode entry
static void fill_share_mode(char *p, files_struct *fsp, uint16 port, uint16 op_type)
{
share_mode_entry *e = (share_mode_entry *)p;
- e->pid = getpid();
+ e->pid = sys_getpid();
e->share_mode = fsp->share_mode;
e->op_port = port;
e->op_type = op_type;
@@ -453,7 +453,7 @@ static BOOL mod_share_mode(files_struct *fsp,
struct locking_data *data;
int i;
share_mode_entry *shares;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
int need_store=0;
/* read in the existing share modes */
diff --git a/source/nmbd/asyncdns.c b/source/nmbd/asyncdns.c
index 99e697b4705..1fe04a39e37 100644
--- a/source/nmbd/asyncdns.c
+++ b/source/nmbd/asyncdns.c
@@ -140,7 +140,7 @@ void start_async_dns(void)
return;
}
- child_pid = fork();
+ child_pid = sys_fork();
if (child_pid) {
fd_in = fd1[0];
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index c7ebe48822a..b59a626fff7 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -652,7 +652,7 @@ static void usage(char *pname)
StartupTime = time(NULL);
- sys_srandom(time(NULL) ^ getpid());
+ sys_srandom(time(NULL) ^ sys_getpid());
TimeInit();
diff --git a/source/nmbd/nmbd_packets.c b/source/nmbd/nmbd_packets.c
index a7c94f15446..ee2ba2e2401 100644
--- a/source/nmbd/nmbd_packets.c
+++ b/source/nmbd/nmbd_packets.c
@@ -140,7 +140,7 @@ static uint16 generate_name_trn_id(void)
if (!name_trn_id)
{
- name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)getpid()%(unsigned)100);
+ name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)sys_getpid()%(unsigned)100);
}
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
return name_trn_id;
diff --git a/source/nmbd/nmbd_synclists.c b/source/nmbd/nmbd_synclists.c
index 7bf17903778..b69a9959c22 100644
--- a/source/nmbd/nmbd_synclists.c
+++ b/source/nmbd/nmbd_synclists.c
@@ -153,7 +153,7 @@ void sync_browse_lists(struct work_record *work,
/* the parent forks and returns, leaving the child to do the
actual sync */
CatchChild();
- if ((s->pid = fork())) return;
+ if ((s->pid = sys_fork())) return;
BlockSignals( False, SIGTERM );
diff --git a/source/nmbd/nmbd_winsserver.c b/source/nmbd/nmbd_winsserver.c
index 2b99a8ce53b..33b33040cb2 100644
--- a/source/nmbd/nmbd_winsserver.c
+++ b/source/nmbd/nmbd_winsserver.c
@@ -1592,14 +1592,14 @@ void wins_write_database(BOOL background)
doesn't block while this is done */
if (background) {
CatchChild();
- if (fork()) {
+ if (sys_fork()) {
return;
}
}
slprintf(fname,sizeof(fname),"%s/%s", lp_lockdir(), WINS_LIST);
all_string_sub(fname,"//", "/", 0);
- slprintf(fnamenew,sizeof(fnamenew),"%s.%u", fname, (unsigned int)getpid());
+ slprintf(fnamenew,sizeof(fnamenew),"%s.%u", fname, (unsigned int)sys_getpid());
if((fp = sys_fopen(fnamenew,"w")) == NULL)
{
diff --git a/source/passdb/pass_check.c b/source/passdb/pass_check.c
index c3e56697476..0496ed9961f 100644
--- a/source/passdb/pass_check.c
+++ b/source/passdb/pass_check.c
@@ -439,7 +439,7 @@ static BOOL dfs_auth(char *user, char *password)
}
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
- user, getpid()));
+ user, sys_getpid()));
DEBUG(3, ("DCE principal: %s\n"
" uid: %d\n"
@@ -487,7 +487,7 @@ void dfs_unlogin(void)
dce_error_inq_text(err, dce_errstr, &err2);
DEBUG(0,
("DCE purge login context failed for server instance %d: %s\n",
- getpid(), dce_errstr));
+ sys_getpid(), dce_errstr));
}
}
#endif
@@ -595,7 +595,7 @@ static BOOL krb4_auth(char *user, char *password)
}
(void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
- (int)getpid());
+ (int)sys_getpid());
krb_set_tkt_string(tkfile);
if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
diff --git a/source/passdb/smbpass.c b/source/passdb/smbpass.c
index 7aad0483397..bfb3946b1af 100644
--- a/source/passdb/smbpass.c
+++ b/source/passdb/smbpass.c
@@ -1106,7 +1106,7 @@ static BOOL del_smbfilepwd_entry(const char *name)
FILE *fp_write = NULL;
int pfile2_lockdepth = 0;
- slprintf(pfile2, sizeof(pfile2)-1, "%s.%u", pfile, (unsigned)getpid() );
+ slprintf(pfile2, sizeof(pfile2)-1, "%s.%u", pfile, (unsigned)sys_getpid() );
/*
* Open the smbpassword file - for update. It needs to be update
diff --git a/source/printing/printing.c b/source/printing/printing.c
index 2f36cf2f3f2..95aa50fb431 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -67,12 +67,12 @@ Does not survive a fork
****************************************************************************/
BOOL print_backend_init(void)
{
- if (tdb && local_pid == getpid()) return True;
+ if (tdb && local_pid == sys_getpid()) return True;
tdb = tdb_open(lock_path("printing.tdb"), 0, 0, O_RDWR|O_CREAT, 0600);
if (!tdb) {
DEBUG(0,("Failed to open printing backend database\n"));
}
- local_pid = getpid();
+ local_pid = sys_getpid();
/* handle a Samba upgrade */
tdb_writelock(tdb);
diff --git a/source/rpc_server/srv_lsa_hnd.c b/source/rpc_server/srv_lsa_hnd.c
index 937da42ec8b..58a7dc6913f 100644
--- a/source/rpc_server/srv_lsa_hnd.c
+++ b/source/rpc_server/srv_lsa_hnd.c
@@ -76,7 +76,7 @@ static void create_pol_hnd(POLICY_HND *hnd)
SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */
SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */
SIVAL(hnd->data, 12, time(NULL)); /* something random */
- SIVAL(hnd->data, 16, getpid()); /* something more random */
+ SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
}
/****************************************************************************
diff --git a/source/rpc_server/srv_pipe_hnd.c b/source/rpc_server/srv_pipe_hnd.c
index 2d11c5eda51..7110342383f 100644
--- a/source/rpc_server/srv_pipe_hnd.c
+++ b/source/rpc_server/srv_pipe_hnd.c
@@ -144,7 +144,7 @@ static void attempt_remote_rpc_connect(pipes_struct *p)
*/
become_root(False); /* to connect to pipe */
- p->m = msrpc_use_add(p->name, getpid(), &usr, False);
+ p->m = msrpc_use_add(p->name, sys_getpid(), &usr, False);
unbecome_root(False);
if (p->m == NULL)
@@ -170,7 +170,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name,
log files and prevents client bugs where pipe numbers are reused
over connection restarts */
if (next_pipe == 0)
- next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES;
+ next_pipe = (sys_getpid() ^ time(NULL)) % MAX_OPEN_PIPES;
i = bitmap_find(bmap, next_pipe);
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index 1daa7e55da6..2680c3a553d 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -135,7 +135,7 @@ static void create_printer_hnd(POLICY_HND *hnd)
SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */
SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */
SIVAL(hnd->data, 12, time(NULL)); /* something random */
- SIVAL(hnd->data, 16, getpid()); /* something more random */
+ SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
}
/****************************************************************************
diff --git a/source/smbd/chgpasswd.c b/source/smbd/chgpasswd.c
index 484523bd272..708b52f4bcd 100644
--- a/source/smbd/chgpasswd.c
+++ b/source/smbd/chgpasswd.c
@@ -330,7 +330,7 @@ static BOOL chat_with_program(char *passwordprogram, char *name,
CatchChildLeaveStatus();
- if ((pid = fork()) < 0)
+ if ((pid = sys_fork()) < 0)
{
DEBUG(3,
("Cannot fork() child for password change: %s\n",
diff --git a/source/smbd/connection.c b/source/smbd/connection.c
index 9c859e4d896..aa49f8cf7cf 100644
--- a/source/smbd/connection.c
+++ b/source/smbd/connection.c
@@ -45,7 +45,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
DEBUG(3,("Yielding connection to %s\n",name));
ZERO_STRUCT(key);
- key.pid = getpid();
+ key.pid = sys_getpid();
if (conn) key.cnum = conn->cnum;
fstrcpy(key.name, name);
@@ -84,7 +84,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
DEBUG(5,("claiming %s %d\n",name,max_connections));
ZERO_STRUCT(key);
- key.pid = getpid();
+ key.pid = sys_getpid();
key.cnum = conn?conn->cnum:-1;
fstrcpy(key.name, name);
@@ -94,7 +94,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
/* fill in the crec */
ZERO_STRUCT(crec);
crec.magic = 0x280267;
- crec.pid = getpid();
+ crec.pid = sys_getpid();
crec.cnum = conn?conn->cnum:-1;
if (conn) {
crec.uid = conn->uid;
diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c
index 8f8f17563e4..2d83378b3de 100644
--- a/source/smbd/fileio.c
+++ b/source/smbd/fileio.c
@@ -205,7 +205,7 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type)) {
share_mode_entry *share_list = NULL;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
int token = -1;
int num_share_modes = 0;
int i;
diff --git a/source/smbd/files.c b/source/smbd/files.c
index e644f52669f..5b930f99400 100644
--- a/source/smbd/files.c
+++ b/source/smbd/files.c
@@ -55,7 +55,7 @@ files_struct *file_new(void )
increases the chance that the errant client will get an error rather
than causing corruption */
if (first_file == 0) {
- first_file = (getpid() ^ (int)time(NULL)) % real_max_open_files;
+ first_file = (sys_getpid() ^ (int)time(NULL)) % real_max_open_files;
}
i = bitmap_find(file_bmap, first_file);
diff --git a/source/smbd/negprot.c b/source/smbd/negprot.c
index adef4a57f37..e8302a43e6b 100644
--- a/source/smbd/negprot.c
+++ b/source/smbd/negprot.c
@@ -87,7 +87,7 @@ static int reply_lanman1(char *outbuf)
SSVAL(outbuf,smb_vwv4,1);
SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
readbraw writebraw (possibly) */
- SIVAL(outbuf,smb_vwv6,getpid());
+ SIVAL(outbuf,smb_vwv6,sys_getpid());
SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
put_dos_date(outbuf,smb_vwv8,t);
@@ -133,7 +133,7 @@ static int reply_lanman2(char *outbuf)
set_message(outbuf,13,crypt_len,True);
SSVAL(outbuf,smb_vwv1,secword);
- SIVAL(outbuf,smb_vwv6,getpid());
+ SIVAL(outbuf,smb_vwv6,sys_getpid());
if (doencrypt)
memcpy(smb_buf(outbuf), cryptkey, 8);
@@ -226,7 +226,7 @@ static int reply_nt1(char *outbuf)
SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
- SIVAL(outbuf,smb_vwv7+1,getpid()); /* session key */
+ SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */
SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
put_long_date(outbuf+smb_vwv11+1,t);
SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 9aadb39bc97..0c6927ba2a7 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -342,7 +342,7 @@ static int check_share_mode( share_mode_entry *share, int deny_mode,
{
int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
- (share->pid == getpid()),is_executable(fname));
+ (share->pid == sys_getpid()),is_executable(fname));
if ((access_allowed == AFAIL) ||
(!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
@@ -946,7 +946,7 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
share_mode_entry *old_shares = 0;
int num_share_modes;
SMB_STRUCT_STAT sbuf;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
SMB_DEV_T dev;
SMB_INO_T inode;
diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c
index 28ab29d0274..4a363d45e98 100644
--- a/source/smbd/oplock.c
+++ b/source/smbd/oplock.c
@@ -111,7 +111,7 @@ address %lx. Error was %s\n", (long)htonl(INADDR_LOOPBACK), strerror(errno)));
return False;
DEBUG(3,("open_oplock ipc: pid = %d, global_oplock_port = %u\n",
- (int)getpid(), global_oplock_port));
+ (int)sys_getpid(), global_oplock_port));
return True;
}
@@ -1088,7 +1088,7 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
{
char op_break_msg[OPLOCK_BREAK_MSG_LEN];
struct sockaddr_in addr_out;
- pid_t pid = getpid();
+ pid_t pid = sys_getpid();
time_t start_time;
int time_left;
long usec;
@@ -1342,7 +1342,7 @@ void check_kernel_oplocks(void)
set_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
- slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)getpid());
+ slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)sys_getpid());
if(pipe(pfd) != 0) {
DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n",
diff --git a/source/smbd/password.c b/source/smbd/password.c
index f92d31718c2..a8b9050030f 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -53,8 +53,8 @@ void generate_next_challenge(char *challenge)
/* get a sort-of random number */
GetTimeOfDay(&tval);
- v1 = (counter++) + getpid() + tval.tv_sec;
- v2 = (counter++) * getpid() + tval.tv_usec;
+ v1 = (counter++) + sys_getpid() + tval.tv_sec;
+ v2 = (counter++) * sys_getpid() + tval.tv_usec;
SIVAL(challenge,0,v1);
SIVAL(challenge,4,v2);
diff --git a/source/smbd/process.c b/source/smbd/process.c
index b81e8311337..1eb58996678 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -421,7 +421,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
extern int global_smbpid;
if (pid == (pid_t)-1)
- pid = getpid();
+ pid = sys_getpid();
errno = 0;
last_message = type;
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 8e4de78cbfa..574be64553a 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -238,7 +238,7 @@ max can be %d\n",
continue;
}
- if (smbd_server_fd() != -1 && fork()==0) {
+ if (smbd_server_fd() != -1 && sys_fork()==0) {
/* Child code ... */
/* close the listening socket(s) */
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 8e04f7e9896..ebc4c9a7901 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -608,7 +608,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int
dbgtext( "connect to service %s ", lp_servicename(SNUM(conn)) );
dbgtext( "as user %s ", user );
dbgtext( "(uid=%d, gid=%d) ", (int)geteuid(), (int)getegid() );
- dbgtext( "(pid %d)\n", (int)getpid() );
+ dbgtext( "(pid %d)\n", (int)sys_getpid() );
}
/* we've finished with the sensitive stuff */