lib/util: Remove obsolete sys_getpid() and sys_fork().
authorJelmer Vernooij <jelmer@samba.org>
Sat, 24 Mar 2012 19:17:08 +0000 (20:17 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 24 Mar 2012 20:55:40 +0000 (21:55 +0100)
The performance of these is minimal (these days) and they can return
invalid results when used as part of applications that do not use
sys_fork().

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Mar 24 21:55:41 CET 2012 on sn-devel-104

49 files changed:
lib/util/become_daemon.c
lib/util/fault.c
lib/util/samba_util.h
lib/util/system.c
source3/auth/pass_check.c
source3/client/client.c
source3/include/rpc_misc.h
source3/lib/ctdbd_conn.c
source3/lib/pidfile.c
source3/lib/server_prefork.c
source3/lib/smbldap.c
source3/lib/smbrun.c
source3/lib/substitute.c
source3/lib/system.c
source3/lib/tdb_validate.c
source3/lib/util.c
source3/libsmb/clientgen.c
source3/libsmb/libsmb_context.c
source3/modules/vfs_aio_fork.c
source3/modules/vfs_notify_fam.c
source3/modules/vfs_preopen.c
source3/nmbd/asyncdns.c
source3/nmbd/nmbd.c
source3/nmbd/nmbd_packets.c
source3/nmbd/nmbd_synclists.c
source3/nmbd/nmbd_winsserver.c
source3/passdb/pdb_smbpasswd.c
source3/passdb/secrets.c
source3/printing/print_cups.c
source3/printing/printing.c
source3/printing/printing_db.c
source3/printing/queue_process.c
source3/printing/spoolssd.c
source3/rpc_server/epmd.c
source3/rpc_server/lsasd.c
source3/rpc_server/rpc_handles.c
source3/rpc_server/samr/srv_samr_chgpasswd.c
source3/rpc_server/svcctl/srv_svcctl_nt.c
source3/smbd/files.c
source3/smbd/negprot.c
source3/smbd/oplock_irix.c
source3/smbd/process.c
source3/smbd/server.c
source3/smbd/service.c
source3/smbd/session.c
source3/smbd/utmp.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_dual.c

index 4c1d29e5a7bbcf221e77b8cb326ae7ca1380ec15..92a75862bdde295bc948c955191944b367c584e1 100644 (file)
@@ -75,7 +75,7 @@ _PUBLIC_ void close_low_fds(bool stdin_too, bool stdout_too, bool stderr_too)
 _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout)
 {
        if (do_fork) {
-               if (sys_fork()) {
+               if (fork()) {
                        _exit(0);
                }
        }
index b3527bb22e695e6402cea3076f0b47271b88e3a9..d0b34e540b432d288708e3191da011ce2bcbb464 100644 (file)
@@ -70,7 +70,7 @@ static void fault_report(int sig)
        counter++;
 
        DEBUGSEP(0);
-       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING));
+       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),SAMBA_VERSION_STRING));
        DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba HOWTO\n"));
        DEBUGSEP(0);
 
index f9892311025ea3a8c592b6bce32977cdb12d38d4..6096722d17177b26f8f3633ca36400036d3956a1 100644 (file)
@@ -113,16 +113,6 @@ void CatchChild(void);
 **/
 void CatchChildLeaveStatus(void);
 
-/**
- * Wrapper for fork used to invalid pid cache.
- **/
-_PUBLIC_ pid_t sys_fork(void);
-
-/**
- * Wrapper for getpid. Ensures we only do a system call *once*.
- **/
-_PUBLIC_ pid_t sys_getpid(void);
-
 struct sockaddr;
 
 _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
index f34fabd29295657ed84e3e69ccd22636e47a1183..558aa5bc12125769e564bdb623caea2cf8ae1c1a 100644 (file)
 */
 
 
-/**************************************************************************
- Wrapper for fork. Ensures we clear our pid cache.
-****************************************************************************/
-
-static pid_t mypid = (pid_t)-1;
-
-_PUBLIC_ 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*.
-****************************************************************************/
-
-_PUBLIC_ pid_t sys_getpid(void)
-{
-       if (mypid == (pid_t)-1)
-               mypid = getpid();
-
-       return mypid;
-}
-
-
 _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa,
                             int salen,
                             char *host,
index 74d6f1ffbc88f38f9af6f88c200a7438819a0535..ca992616788395899a1418481aa80a4b58262745 100644 (file)
@@ -378,7 +378,7 @@ static bool dfs_auth(char *user, char *password)
        }
 
        DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
-                 user, sys_getpid()));
+                 user, getpid()));
 
        DEBUG(3, ("DCE principal: %s\n"
                  "          uid: %d\n"
@@ -431,7 +431,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",
-                      sys_getpid(), dce_errstr));
+                      getpid(), dce_errstr));
        }
 }
 #endif
index 87ec3a996953bd51b56a53d763f7125fb45ac249..0d60103f26f9037ee7154e9506c5b5aaa8376314 100644 (file)
@@ -2292,12 +2292,12 @@ static int cmd_print(void)
                rname = talloc_asprintf(ctx,
                                        "%s-%d",
                                        p+1,
-                                       (int)sys_getpid());
+                                       (int)getpid());
        }
        if (strequal(lname,"-")) {
                rname = talloc_asprintf(ctx,
                                "stdin-%d",
-                               (int)sys_getpid());
+                               (int)getpid());
        }
        if (!rname) {
                return 1;
index adc80167cade5f54a30dbecfae16ce57469a5eb8..a33406a917734cb8ff5a9bee846f45417c035c25 100644 (file)
@@ -28,8 +28,8 @@
  **********************************************************************/
 
 #define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\
-       ( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \
+       ( IVAL((hnd)->uuid.node,2) == (uint32)getpid() ? "OURS" : \
                "OTHER")), ((unsigned int)IVAL((hnd)->uuid.node,2)),\
-               ((unsigned int)sys_getpid() )
+               ((unsigned int)getpid() )
 
 #endif /* _RPC_MISC_H */
index 36e9e508f072c0ff9f128bea16bc52cb3ac86b12..ba511379151338334b353f1e5000415884b1ceeb 100644 (file)
@@ -578,7 +578,7 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       status = register_with_ctdbd(conn, (uint64_t)sys_getpid());
+       status = register_with_ctdbd(conn, (uint64_t)getpid());
        if (!NT_STATUS_IS_OK(status)) {
                goto fail;
        }
@@ -665,7 +665,7 @@ static NTSTATUS ctdb_handle_message(uint8_t *buf, size_t length,
        }
 
        /* only messages to our pid or the broadcast are valid here */
-       if (msg->srvid != sys_getpid() && msg->srvid != MSG_SRVID_SAMBA) {
+       if (msg->srvid != getpid() && msg->srvid != MSG_SRVID_SAMBA) {
                DEBUG(0,("Got unexpected message with srvid=%llu\n", 
                         (unsigned long long)msg->srvid));
                TALLOC_FREE(buf);
index 06fca91165d70c7b2996dd2fb3edeb7ae5f7ae2a..469ddbd95fd83d7c460d7b9ea8df3be7e85cccf9 100644 (file)
@@ -162,7 +162,7 @@ void pidfile_create(const char *program_name)
        }
 
        memset(buf, 0, sizeof(buf));
-       slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
+       slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int)getpid());
        if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
                DEBUG(0,("ERROR: can't write to file %s: %s\n", 
                         pidFile_name, strerror(errno)));
index f9df91417c92167ce2c6e354644e2dd6e4991dfe..3d35e1c6ca6415a9d1d28217865369dcfc552426 100644 (file)
@@ -106,7 +106,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
                pfp->pool[i].allowed_clients = 1;
                pfp->pool[i].started = now;
 
-               pid = sys_fork();
+               pid = fork();
                switch (pid) {
                case -1:
                        DEBUG(1, ("Failed to prefork child n. %d !\n", i));
@@ -194,7 +194,7 @@ int prefork_add_children(struct tevent_context *ev_ctx,
                pfp->pool[i].allowed_clients = 1;
                pfp->pool[i].started = now;
 
-               pid = sys_fork();
+               pid = fork();
                switch (pid) {
                case -1:
                        DEBUG(1, ("Failed to prefork child n. %d !\n", j));
index 51bcabd5ebf58784b0d0da9b2b3b70e74ac16f92..c01d3fdc6921070318c7129ba06862564801f77b 100644 (file)
@@ -1070,7 +1070,7 @@ static int smbldap_open(struct smbldap_state *ldap_state)
 
 
        ldap_state->last_ping = time_mono(NULL);
-       ldap_state->pid = sys_getpid();
+       ldap_state->pid = getpid();
 
        TALLOC_FREE(ldap_state->idle_event);
 
@@ -1157,7 +1157,7 @@ static void setup_ldap_local_alarm(struct smbldap_state *ldap_state, time_t abso
                alarm(absolute_endtime - now);
        }
 
-       if (ldap_state->pid != sys_getpid()) {
+       if (ldap_state->pid != getpid()) {
                smbldap_close(ldap_state);
        }
 }
index 75713d2aa2f022b77ffe31c2270d2fe8584c3968..b38dee1665bcd4379e84f1eb9f5bdf4bad760321 100644 (file)
@@ -92,7 +92,7 @@ static int smbrun_internal(const char *cmd, int *outfd, bool sanitize)
 
        CatchChildLeaveStatus();
                                        
-       if ((pid=sys_fork()) < 0) {
+       if ((pid=fork()) < 0) {
                DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
                CatchChild(); 
                if (outfd) {
@@ -255,7 +255,7 @@ int smbrunsecret(const char *cmd, const char *secret)
 
        CatchChildLeaveStatus();
                                        
-       if ((pid=sys_fork()) < 0) {
+       if ((pid=fork()) < 0) {
                DEBUG(0, ("smbrunsecret: fork failed with error %s\n", strerror(errno)));
                CatchChild(); 
                return errno;
index 08cc03eeb275aba1cbc794390435780c6aacdf44..44582860a19e73d7d31dd3ef694d4158a5adf8a2 100644 (file)
@@ -549,7 +549,7 @@ char *talloc_sub_basic(TALLOC_CTX *mem_ctx,
                                        get_remote_arch_str());
                        break;
                case 'd' :
-                       slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)sys_getpid());
+                       slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)getpid());
                        a_string = realloc_string_sub(a_string, "%d", pidstr);
                        break;
                case 'h' :
index f6558530f329efb0364ecdabea4f11759b948af1..92e244fdbe9a47782f39f04b06395eca3c496879 100644 (file)
@@ -1404,7 +1404,7 @@ int sys_popen(const char *command)
        if(!(argl = extract_args(NULL, command)))
                goto err_exit;
 
-       entry->child_pid = sys_fork();
+       entry->child_pid = fork();
 
        if (entry->child_pid == -1) {
                goto err_exit;
index 385f4d0ef810c9113b2827e274dfab639ba0abdf..e4f752023daac1ebbbb4a3106dd833ba2b04dab8 100644 (file)
@@ -118,7 +118,7 @@ int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn)
         * just let the child panic. we catch the signal. */
 
        DEBUG(10, ("tdb_validate: forking to let child do validation.\n"));
-       child_pid = sys_fork();
+       child_pid = fork();
        if (child_pid == 0) {
                /* child code */
                DEBUG(10, ("tdb_validate (validation child): created\n"));
index 9d3d787d639a91ab6eeee02237222d8bc10c7f7d..7be056c68b09da2c6eedf8bb3806a7221db4f72c 100644 (file)
@@ -860,7 +860,7 @@ void smb_panic_s3(const char *why)
        int result;
 
        DEBUG(0,("PANIC (pid %llu): %s\n",
-                   (unsigned long long)sys_getpid(), why));
+                   (unsigned long long)getpid(), why));
        log_stack_trace();
 
 #if defined(HAVE_PRCTL) && defined(PR_SET_PTRACER)
@@ -1985,7 +1985,7 @@ static uint32 my_vnn = NONCLUSTER_VNN;
 
 void set_my_vnn(uint32 vnn)
 {
-       DEBUG(10, ("vnn pid %d = %u\n", (int)sys_getpid(), (unsigned int)vnn));
+       DEBUG(10, ("vnn pid %d = %u\n", (int)getpid(), (unsigned int)vnn));
        my_vnn = vnn;
 }
 
@@ -2013,7 +2013,7 @@ struct server_id pid_to_procid(pid_t pid)
 
 struct server_id procid_self(void)
 {
-       return pid_to_procid(sys_getpid());
+       return pid_to_procid(getpid());
 }
 
 bool procid_equal(const struct server_id *p1, const struct server_id *p2)
@@ -2035,7 +2035,7 @@ bool cluster_id_equal(const struct server_id *id1,
 
 bool procid_is_me(const struct server_id *pid)
 {
-       if (pid->pid != sys_getpid())
+       if (pid->pid != getpid())
                return False;
        if (pid->task_id != 0)
                return False;
index 26fbd196163cacbaea301ac8fc22e2094d0f566f..75948b8e998432f79e6280a554d6ccd135bfdab7 100644 (file)
@@ -271,7 +271,7 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
                goto error;
        }
 
-       cli->smb1.pid = (uint16_t)sys_getpid();
+       cli->smb1.pid = (uint16_t)getpid();
        cli->smb1.vc_num = cli->smb1.pid;
        cli->smb1.tid = UINT16_MAX;
        cli->smb1.uid = UID_FIELD_INVALID;
index 6c78cb93d7c959f014a43f215b6fb86d359b5329..a8fd2dc45ee4a0c8e95c905c5f019e9a2baba012 100644 (file)
@@ -604,7 +604,7 @@ smbc_init_context(SMBCCTX *context)
                          * Hmmm, I want to get hostname as well, but I am too
                          * lazy for the moment
                          */
-                        pid = sys_getpid();
+                        pid = getpid();
                         netbios_name = (char *)SMB_MALLOC(17);
                         if (!netbios_name) {
                                 errno = ENOMEM;
index bcd7c6ae2d0cb506ca1240435dd01abd5d2a980e..27f71165cf98c1e83d81d8ed64306d45e656946a 100644 (file)
@@ -500,7 +500,7 @@ static NTSTATUS create_aio_child(struct smbd_server_connection *sconn,
                goto fail;
        }
 
-       result->pid = sys_fork();
+       result->pid = fork();
        if (result->pid == -1) {
                status = map_nt_error_from_unix(errno);
                DEBUG(0, ("fork failed: %s\n", strerror(errno)));
index 8a3487b9d35a9e250fe3e781fc92224e68afe3fb..7ac6609c5304fb744da61059d1777600345a5c8e 100644 (file)
@@ -87,7 +87,7 @@ static NTSTATUS fam_open_connection(FAMConnection *fam_conn,
        setenv("GAM_CLIENT_ID","SAMBA",0);
 #endif
 
-       if (asprintf(&name, "smbd (%lu)", (unsigned long)sys_getpid()) == -1) {
+       if (asprintf(&name, "smbd (%lu)", (unsigned long)getpid()) == -1) {
                DEBUG(0, ("No memory\n"));
                return NT_STATUS_NO_MEMORY;
        }
index 3d7f6c1b03844b9b5ce61d78b33c01a0db8b7d51..3540d34c4fa28e776f913e670ed204a998c30c3f 100644 (file)
@@ -224,7 +224,7 @@ static NTSTATUS preopen_init_helper(struct preopen_helper *h)
                return status;
        }
 
-       h->pid = sys_fork();
+       h->pid = fork();
 
        if (h->pid == -1) {
                return map_nt_error_from_unix(errno);
index a42ad25c20bd5485464400e5b5dd956785394b75..90340efe3970600195f9f2462da0303adbcbec76 100644 (file)
@@ -147,7 +147,7 @@ void start_async_dns(struct messaging_context *msg)
                return;
        }
 
-       child_pid = sys_fork();
+       child_pid = fork();
 
        if (child_pid) {
                fd_in = fd1[0];
index eff1eca2f1657ae6cef69030775e21d54f347e19..bb264d2274009f8dd46fe069435707683d5b7f9f 100644 (file)
@@ -830,7 +830,7 @@ static bool open_sockets(bool isdaemon, int port)
 
        StartupTime = time(NULL);
 
-       sys_srandom(time(NULL) ^ sys_getpid());
+       sys_srandom(time(NULL) ^ getpid());
 
        if (!override_logfile) {
                char *lfile = NULL;
index f8bfe45c8594375012fd7b9b3442176b22198fad..7a707a045b989ffeae62da8c6b4af926b0a75eaa 100644 (file)
@@ -150,7 +150,7 @@ static uint16 name_trn_id=0;
 static uint16 generate_name_trn_id(void)
 {
        if (!name_trn_id) {
-               name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)sys_getpid()%(unsigned)100);
+               name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)getpid()%(unsigned)100);
        }
        name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
        return name_trn_id;
index 1adccbd7d3541d74983d7b15fde6dab59c150be6..20ece6915a0ca169a7856845b68f328e2015d932 100644 (file)
@@ -167,7 +167,7 @@ done:
        /* the parent forks and returns, leaving the child to do the
           actual sync and call END_PROFILE*/
        CatchChild();
-       if ((s->pid = sys_fork())) return;
+       if ((s->pid = fork())) return;
 
        BlockSignals( False, SIGTERM );
 
index 48c10e25aece4cf4ebd23e1243bc3b32c98d930d..0a06ebea66798751e8a8d56e025ae82de0b4de32 100644 (file)
@@ -2470,7 +2470,7 @@ void wins_write_database(time_t t, bool background)
        /* We will do the writing in a child process to ensure that the parent doesn't block while this is done */
        if (background) {
                CatchChild();
-               if (sys_fork()) {
+               if (fork()) {
                        return;
                }
                if (tdb_reopen(wins_tdb)) {
@@ -2487,7 +2487,7 @@ void wins_write_database(time_t t, bool background)
        /* This is safe as the 0 length means "don't expand". */
        all_string_sub(fname,"//", "/", 0);
 
-       if (asprintf(&fnamenew, "%s.%u", fname, (unsigned int)sys_getpid()) < 0) {
+       if (asprintf(&fnamenew, "%s.%u", fname, (unsigned int)getpid()) < 0) {
                goto err_exit;
        }
 
index 6dbb72a577db62e8f9c32754db9815d8c524eab3..4d5bed4e10ba59e12c54817e1fc9e7d5b23f307c 100644 (file)
@@ -1095,7 +1095,7 @@ static bool del_smbfilepwd_entry(struct smbpasswd_privates *smbpasswd_state, con
 
        pfile2 = talloc_asprintf(talloc_tos(),
                        "%s.%u",
-                       pfile, (unsigned)sys_getpid());
+                       pfile, (unsigned)getpid());
        if (!pfile2) {
                return false;
        }
index 94e514d2189713cc079d7a4fb97af2d9f63b0933..33a266c2af7e2c576e6ea7ded704f0c354271f9f 100644 (file)
@@ -47,7 +47,7 @@ static struct db_context *db_ctx;
  */
 static void get_rand_seed(void *userdata, int *new_seed)
 {
-       *new_seed = sys_getpid();
+       *new_seed = getpid();
        if (db_ctx) {
                dbwrap_trans_change_int32_atomic(db_ctx, "INFO/random_seed",
                                                 new_seed, 1);
index 95ddd570bb797bd3e387e824c3c9a479971d784c..79b146c076af4512f604ac7923ca6146b6b29e82 100644 (file)
@@ -411,7 +411,7 @@ static bool cups_pcap_load_async(struct tevent_context *ev,
                return false;
        }
 
-       pid = sys_fork();
+       pid = fork();
        if (pid == (pid_t)-1) {
                DEBUG(10,("cups_pcap_load_async: fork failed %s\n",
                        strerror(errno) ));
index f3a9a9a2538d1ef88e7b1e40e87a30ed4de5f10c..0d943a38dfe3774f91f46cf45002fc14e7811c5c 100644 (file)
@@ -1111,7 +1111,7 @@ static void set_updating_pid(const fstring sharename, bool updating)
        fstring keystr;
        TDB_DATA key;
        TDB_DATA data;
-       pid_t updating_pid = sys_getpid();
+       pid_t updating_pid = getpid();
        uint8 buffer[4];
 
        struct tdb_print_db *pdb = get_print_db_byname(sharename);
@@ -1752,7 +1752,7 @@ bool print_notify_register_pid(int snum)
        struct tdb_print_db *pdb = NULL;
        TDB_CONTEXT *tdb = NULL;
        const char *printername;
-       uint32 mypid = (uint32)sys_getpid();
+       uint32_t mypid = (uint32_t)getpid();
        bool ret = False;
        size_t i;
 
@@ -1843,7 +1843,7 @@ bool print_notify_deregister_pid(int snum)
        struct tdb_print_db *pdb = NULL;
        TDB_CONTEXT *tdb = NULL;
        const char *printername;
-       uint32 mypid = (uint32)sys_getpid();
+       uint32_t mypid = (uint32_t)getpid();
        size_t i;
        bool ret = False;
 
@@ -1948,7 +1948,7 @@ bool print_job_exists(const char* sharename, uint32 jobid)
 char *print_job_fname(const char* sharename, uint32 jobid)
 {
        struct printjob *pjob = print_job_find(sharename, jobid);
-       if (!pjob || pjob->spooled || pjob->pid != sys_getpid())
+       if (!pjob || pjob->spooled || pjob->pid != getpid())
                return NULL;
        return pjob->filename;
 }
@@ -1981,7 +1981,7 @@ bool print_job_set_name(struct tevent_context *ev,
        struct printjob *pjob;
 
        pjob = print_job_find(sharename, jobid);
-       if (!pjob || pjob->pid != sys_getpid())
+       if (!pjob || pjob->pid != getpid())
                return False;
 
        fstrcpy(pjob->jobname, name);
@@ -1997,7 +1997,7 @@ bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t job
        struct printjob *pjob;
 
        pjob = print_job_find(sharename, jobid);
-       if (!pjob || pjob->pid != sys_getpid()) {
+       if (!pjob || pjob->pid != getpid()) {
                return false;
        }
 
@@ -2361,7 +2361,7 @@ ssize_t print_job_write(struct tevent_context *ev,
        if (!pjob)
                return -1;
        /* don't allow another process to get this info - it is meaningless */
-       if (pjob->pid != sys_getpid())
+       if (pjob->pid != getpid())
                return -1;
 
        /* if SMBD is spooling this can't be allowed */
@@ -2720,7 +2720,7 @@ WERROR print_job_start(const struct auth_session_info *server_info,
 
        ZERO_STRUCT(pjob);
 
-       pjob.pid = sys_getpid();
+       pjob.pid = getpid();
        pjob.sysjob = -1;
        pjob.fd = -1;
        pjob.starttime = time(NULL);
@@ -2788,7 +2788,7 @@ void print_job_endpage(struct messaging_context *msg_ctx,
        if (!pjob)
                return;
        /* don't allow another process to get this info - it is meaningless */
-       if (pjob->pid != sys_getpid())
+       if (pjob->pid != getpid())
                return;
 
        pjob->page_count++;
@@ -2817,7 +2817,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
                return NT_STATUS_PRINT_CANCELLED;
        }
 
-       if (pjob->spooled || pjob->pid != sys_getpid()) {
+       if (pjob->spooled || pjob->pid != getpid()) {
                return NT_STATUS_ACCESS_DENIED;
        }
 
index a3e10659d65a577abbf8159533f1cebca90262b5..ecb8ff6463cffa579f2e86bd02f4b7c17ad154c2 100644 (file)
@@ -193,7 +193,7 @@ TDB_DATA get_printer_notify_pid_list(struct tdb_context *tdb, const char *printe
        for( i = 0; i < data.dsize; i += 8) {
                pid_t pid = (pid_t)IVAL(data.dptr, i);
 
-               if (pid == sys_getpid())
+               if (pid == getpid())
                        continue;
 
                /* Entry is dead if process doesn't exist or refcount is zero. */
index de41f8916d6323667b3d00f59779161202b509fd..6e50f5f4ff3f89277f35a0542c5828638fa0f435 100644 (file)
@@ -244,7 +244,7 @@ pid_t start_background_queue(struct tevent_context *ev,
        BlockSignals(true, SIGTERM);
        BlockSignals(true, SIGHUP);
 
-       pid = sys_fork();
+       pid = fork();
 
        /* parent or error */
        if (pid != 0) {
index 577550516084d55197685b1eaa93720e93ee7aae..f4bba76bc7ed40405d344f0ea2073c6ca45bc11f 100644 (file)
@@ -644,7 +644,7 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
        BlockSignals(true, SIGTERM);
        BlockSignals(true, SIGHUP);
 
-       pid = sys_fork();
+       pid = fork();
 
        if (pid == -1) {
                DEBUG(0, ("Failed to fork SPOOLSS [%s]\n",
index c28d8574c0df993bb4a6776df068da51e0e33d80..46b5c52bb7778134fa14801f8514b88ded6662e7 100644 (file)
@@ -146,7 +146,7 @@ void start_epmd(struct tevent_context *ev_ctx,
 
        DEBUG(1, ("Forking Endpoint Mapper Daemon\n"));
 
-       pid = sys_fork();
+       pid = fork();
 
        if (pid == -1) {
                DEBUG(0, ("Failed to fork Endpoint Mapper [%s], aborting ...\n",
index ad184d89c951523dd84d83b267dad6c2c24ac3b0..6608d6ba33279fabc4804b51e052beb7ff33533f 100644 (file)
@@ -858,7 +858,7 @@ void start_lsasd(struct tevent_context *ev_ctx,
        BlockSignals(true, SIGTERM);
        BlockSignals(true, SIGHUP);
 
-       pid = sys_fork();
+       pid = fork();
        if (pid == -1) {
                DEBUG(0, ("Failed to fork LSASD [%s], aborting ...\n",
                           strerror(errno)));
index f98b2355fc3f88a9c693f880fed2716cafa428f3..d0b9777f6f03449ec9556a70a4923a0f63ab73e1 100644 (file)
@@ -292,7 +292,7 @@ static struct dcesrv_handle *create_rpc_handle_internal(struct pipes_struct *p,
        /* something random */
        SSVAL(rpc_hnd->wire_handle.uuid.node, 0, t);
        /* something more random */
-       SIVAL(rpc_hnd->wire_handle.uuid.node, 2, sys_getpid());
+       SIVAL(rpc_hnd->wire_handle.uuid.node, 2, getpid());
 
        DLIST_ADD(p->pipe_handles->handles, rpc_hnd);
        p->pipe_handles->count++;
index 083b048afe0acd8d754fefb4626dc4acd36f7938..1e8b14ead7fc05b89f6993fdd504b1172974b547 100644 (file)
@@ -405,7 +405,7 @@ static bool chat_with_program(char *passwordprogram, const struct passwd *pass,
 
        CatchChildLeaveStatus();
 
-       if ((pid = sys_fork()) < 0) {
+       if ((pid = fork()) < 0) {
                DEBUG(3, ("chat_with_program: Cannot fork() child for password change: %s\n", pass->pw_name));
                SAFE_FREE(slavedev);
                close(master);
index 37cfc46d58bc6e9315a7f92d71f7aff8a28d9b25..74c55ab52198914736e51d4a296e768542eeac1f 100644 (file)
@@ -637,7 +637,7 @@ WERROR _svcctl_QueryServiceStatusEx(struct pipes_struct *p,
 
                        /* Get the status of the service.. */
                        info->ops->service_status( info->name, &svc_stat_proc.status );
-                       svc_stat_proc.process_id     = sys_getpid();
+                       svc_stat_proc.process_id     = getpid();
                        svc_stat_proc.service_flags  = 0x0;
 
                        ndr_err = ndr_push_struct_blob(&blob, p->mem_ctx, &svc_stat_proc,
index 6499a810ffc7300b9e75d90d269f5f53eafb4cba..e01a92e333de0c5ed566fec2adf322b2b901543e 100644 (file)
@@ -60,7 +60,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
           increases the chance that the errant client will get an error rather
           than causing corruption */
        if (sconn->first_file == 0) {
-               sconn->first_file = (sys_getpid() ^ (int)time(NULL));
+               sconn->first_file = (getpid() ^ (int)time(NULL));
                sconn->first_file %= sconn->real_max_open_files;
        }
 
index e44ac5cb751cb0f0e0b1c9b091b8bb96ef212896..9ddafee657a221ba0c3b5242787b2b6ee964ef5d 100644 (file)
@@ -121,13 +121,13 @@ static void reply_lanman1(struct smb_request *req, uint16 choice)
        set_Protocol(PROTOCOL_LANMAN1);
 
        /* Reply, SMBlockread, SMBwritelock supported. */
-       SCVAL(req->outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
-       SSVAL(req->outbuf,smb_vwv2,sconn->smb1.negprot.max_recv);
-       SSVAL(req->outbuf,smb_vwv3,lp_maxmux()); /* maxmux */
-       SSVAL(req->outbuf,smb_vwv4,1);
-       SSVAL(req->outbuf,smb_vwv5,raw); /* tell redirector we support
+       SCVAL(req->outbuf,smb_flg, FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
+       SSVAL(req->outbuf,smb_vwv2, sconn->smb1.negprot.max_recv);
+       SSVAL(req->outbuf,smb_vwv3, lp_maxmux()); /* maxmux */
+       SSVAL(req->outbuf,smb_vwv4, 1);
+       SSVAL(req->outbuf,smb_vwv5, raw); /* tell redirector we support
                readbraw writebraw (possibly) */
-       SIVAL(req->outbuf,smb_vwv6,sys_getpid());
+       SIVAL(req->outbuf,smb_vwv6, getpid());
        SSVAL(req->outbuf,smb_vwv10, set_server_zone_offset(t)/60);
 
        srv_put_dos_date((char *)req->outbuf,smb_vwv8,t);
@@ -157,9 +157,9 @@ static void reply_lanman2(struct smb_request *req, uint16 choice)
 
        reply_outbuf(req, 13, sconn->smb1.negprot.encrypted_passwords?8:0);
 
-       SSVAL(req->outbuf,smb_vwv0,choice);
-       SSVAL(req->outbuf,smb_vwv1,secword);
-       SIVAL(req->outbuf,smb_vwv6,sys_getpid());
+       SSVAL(req->outbuf,smb_vwv0, choice);
+       SSVAL(req->outbuf,smb_vwv1, secword);
+       SIVAL(req->outbuf,smb_vwv6, getpid());
 
        /* Create a token value and add it to the outgoing packet. */
        if (sconn->smb1.negprot.encrypted_passwords) {
@@ -362,13 +362,13 @@ static void reply_nt1(struct smb_request *req, uint16 choice)
 
        set_Protocol(PROTOCOL_NT1);
 
-       SSVAL(req->outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */
-       SSVAL(req->outbuf,smb_vwv2+1,1); /* num vcs */
+       SSVAL(req->outbuf,smb_vwv1+1, lp_maxmux()); /* maxmpx */
+       SSVAL(req->outbuf,smb_vwv2+1, 1); /* num vcs */
        SIVAL(req->outbuf,smb_vwv3+1,
              sconn->smb1.negprot.max_recv); /* max buffer. LOTS! */
-       SIVAL(req->outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
-       SIVAL(req->outbuf,smb_vwv7+1,sys_getpid()); /* session key */
-       SIVAL(req->outbuf,smb_vwv9+1,capabilities); /* capabilities */
+       SIVAL(req->outbuf,smb_vwv5+1, 0x10000); /* raw size. full 64k */
+       SIVAL(req->outbuf,smb_vwv7+1, getpid()); /* session key */
+       SIVAL(req->outbuf,smb_vwv9+1, capabilities); /* capabilities */
        clock_gettime(CLOCK_REALTIME,&ts);
        put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER,(char *)req->outbuf+smb_vwv11+1,ts);
        SSVALS(req->outbuf,smb_vwv15+1,set_server_zone_offset(ts.tv_sec)/60);
index 0bc964ffff682a11baf9e95a178e33ed5cd31f1e..2097945b975d83ac6d032bbb9db60e42e4f0514b 100644 (file)
@@ -50,7 +50,7 @@ static bool irix_oplocks_available(void)
        tmpname = talloc_asprintf(ctx,
                                "%s/koplock.%d",
                                lp_lockdir(),
-                               (int)sys_getpid());
+                               (int)getpid());
        if (!tmpname) {
                TALLOC_FREE(ctx);
                return False;
index defedf6d6ce1e66486d28e970bada65be8a552d8..ed19e7f42bf1aa8ae946509237d552a1cedae2fb 100644 (file)
@@ -76,7 +76,7 @@ static bool smbd_lock_socket_internal(struct smbd_server_connection *sconn)
                return true;
        }
 
-       DEBUG(10,("pid[%d] wait for socket lock\n", (int)sys_getpid()));
+       DEBUG(10,("pid[%d] wait for socket lock\n", (int)getpid()));
 
        do {
                ok = fcntl_lock(
@@ -89,7 +89,7 @@ static bool smbd_lock_socket_internal(struct smbd_server_connection *sconn)
                return false;
        }
 
-       DEBUG(10,("pid[%d] got for socket lock\n", (int)sys_getpid()));
+       DEBUG(10,("pid[%d] got for socket lock\n", (int)getpid()));
 
        return true;
 }
@@ -126,7 +126,7 @@ static bool smbd_unlock_socket_internal(struct smbd_server_connection *sconn)
                return false;
        }
 
-       DEBUG(10,("pid[%d] unlocked socket\n", (int)sys_getpid()));
+       DEBUG(10,("pid[%d] unlocked socket\n", (int)getpid()));
 
        return true;
 }
@@ -182,7 +182,7 @@ bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
                 * client failed.
                 */
                DEBUG(1,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n",
-                        (int)sys_getpid(), (int)len,
+                        (int)getpid(), (int)len,
                         get_peer_addr(sconn->sock, addr, sizeof(addr)),
                         (int)ret, strerror(errno) ));
 
@@ -1373,7 +1373,7 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req)
        conn = req->conn;
 
        DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type),
-                (int)sys_getpid(), (unsigned long)conn));
+                (int)getpid(), (unsigned long)conn));
 
        smb_dump(smb_fn_name(type), 1, (const char *)req->inbuf);
 
@@ -2638,7 +2638,7 @@ static void smbd_echo_read_waited(struct tevent_req *subreq)
 
        if (!fd_is_readable(sconn->sock)) {
                DEBUG(10,("echo_handler[%d] the parent smbd was faster\n",
-                         (int)sys_getpid()));
+                         (int)getpid()));
 
                ok = smbd_unlock_socket_internal(sconn);
                if (!ok) {
@@ -2667,7 +2667,7 @@ static void smbd_echo_read_waited(struct tevent_req *subreq)
        if (tevent_req_nterror(req, status)) {
                tevent_req_nterror(req, status);
                DEBUG(1, ("echo_handler[%d]: receive_smb_raw_talloc failed: %s\n",
-                         (int)sys_getpid(), nt_errstr(status)));
+                         (int)getpid(), nt_errstr(status)));
                return;
        }
 
@@ -2751,7 +2751,7 @@ static void smbd_echo_writer_done(struct tevent_req *req)
                DEBUG(1, ("writev to parent failed: %s\n", strerror(err)));
                exit(1);
        }
-       DEBUG(10,("echo_handler[%d]: forwarded pdu to main\n", (int)sys_getpid()));
+       DEBUG(10,("echo_handler[%d]: forwarded pdu to main\n", (int)getpid()));
        smbd_echo_activate_writer(state);
 }
 
@@ -2932,7 +2932,7 @@ static void smbd_echo_got_packet(struct tevent_req *req)
                iov->iov_len = buflen;
 
                DEBUG(10,("echo_handler[%d]: forward to main\n",
-                         (int)sys_getpid()));
+                         (int)getpid()));
                smbd_echo_activate_writer(state);
        }
 
@@ -2965,7 +2965,7 @@ bool fork_echo_handler(struct smbd_server_connection *sconn)
                goto fail;
        }
 
-       child = sys_fork();
+       child = fork();
        if (child == 0) {
                NTSTATUS status;
 
@@ -2987,7 +2987,7 @@ bool fork_echo_handler(struct smbd_server_connection *sconn)
        listener_pipe[1] = -1;
        sconn->smb1.echo_handler.trusted_fd = listener_pipe[0];
 
-       DEBUG(10,("fork_echo_handler: main[%d] echo_child[%d]\n", (int)sys_getpid(), child));
+       DEBUG(10,("fork_echo_handler: main[%d] echo_child[%d]\n", (int)getpid(), child));
 
        /*
         * Without smb signing this is the same as the normal smbd
index ef3f140f78e2db551434ee070c6d7eba5f27be14..d3bcc48893e9c8cb25a7eab170abe70521173ba0 100644 (file)
@@ -184,7 +184,7 @@ static void msg_inject_fault(struct messaging_context *msg,
                  procid_str_static(&src), sig));
 #endif
 
-       kill(sys_getpid(), sig);
+       kill(getpid(), sig);
 }
 #endif /* DEVELOPER */
 
@@ -484,7 +484,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
         */
        unique_id = serverid_get_random_unique_id();
 
-       pid = sys_fork();
+       pid = fork();
        if (pid == 0) {
                NTSTATUS status = NT_STATUS_OK;
 
@@ -545,7 +545,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
        }
 
        if (pid < 0) {
-               DEBUG(0,("smbd_accept_connection: sys_fork() failed: %s\n",
+               DEBUG(0,("smbd_accept_connection: fork() failed: %s\n",
                         strerror(errno)));
        }
 
index 867776571b263b67b6c5605c89eb6a14b9a636df..c4d3486cdf6b662c816bed34e7bbc83345af8591 100644 (file)
@@ -874,7 +874,7 @@ static NTSTATUS make_connection_snum(struct smbd_server_connection *sconn,
                dbgtext( "initially as user %s ",
                         conn->session_info->unix_info->unix_name );
                dbgtext( "(uid=%d, gid=%d) ", (int)effuid, (int)effgid );
-               dbgtext( "(pid %d)\n", (int)sys_getpid() );
+               dbgtext( "(pid %d)\n", (int)getpid() );
        }
 
        return status;
index 1d89122ddd7a77258966a19478478687ff5d332f..e03af1e0304f6ebcc07b463347617e337eeb12e9 100644 (file)
@@ -129,7 +129,7 @@ bool session_claim(struct smbd_server_connection *sconn, user_struct *vuser)
                }
 
                snprintf(sessionid.id_str, sizeof(sessionid.id_str),
-                        SESSION_TEMPLATE, (long unsigned int)sys_getpid(),
+                        SESSION_TEMPLATE, (long unsigned int)getpid(),
                         vuser->vuid);
        }
 
index 6837c078cfe7e6fc778e469d7f860576ffd721e1..34b77616b6a61d9e0af6ed06414c5efe86245155 100644 (file)
@@ -528,7 +528,7 @@ static bool sys_utmp_fill(struct utmp *u,
        utmp_strcpy(u->ut_line, id_str, sizeof(u->ut_line));
 
 #if defined(HAVE_UT_UT_PID)
-       u->ut_pid = sys_getpid();
+       u->ut_pid = getpid();
 #endif
 
 /*
index 66e53d9caec6ad2fe0cfa89308ba45afc20d72c3..a3b21425a000c22fc0ce17c42632e9688ab6db73 100644 (file)
@@ -431,7 +431,7 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
         * so we don't block the main winbindd and the validation
         * code can safely use fork/waitpid...
         */
-       child_pid = sys_fork();
+       child_pid = fork();
 
        if (child_pid == -1) {
                DEBUG(1, ("winbind_msg_validate_cache: Could not fork: %s\n",
index 020a092f296622c9fa775366d633d9158b7e2627..edd50d12bc1a89f9820b68f1f3876a71ec2bc337 100644 (file)
@@ -188,7 +188,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
        struct dc_name_ip *dcs = NULL;
        int num_dcs = 0;
        TALLOC_CTX *mem_ctx = NULL;
-       pid_t parent_pid = sys_getpid();
+       pid_t parent_pid = getpid();
        char *lfile = NULL;
        NTSTATUS status;
 
@@ -206,7 +206,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
                domain->dc_probe_pid = (pid_t)-1;
        }
 
-       domain->dc_probe_pid = sys_fork();
+       domain->dc_probe_pid = fork();
 
        if (domain->dc_probe_pid == (pid_t)-1) {
                DEBUG(0, ("fork_child_dc_connect: Could not fork: %s\n", strerror(errno)));
index f11dae7e0827e628ed8063d02a8c52221c657046..4eef550b4b8fc9bcff4ced301eadba363a213d6e 100644 (file)
@@ -1312,11 +1312,11 @@ static bool fork_domain_child(struct winbindd_child *child)
        }
 
        ZERO_STRUCT(state);
-       state.pid = sys_getpid();
+       state.pid = getpid();
        state.request = &request;
        state.response = &response;
 
-       child->pid = sys_fork();
+       child->pid = fork();
 
        if (child->pid == -1) {
                DEBUG(0, ("Could not fork: %s\n", strerror(errno)));
@@ -1353,7 +1353,7 @@ static bool fork_domain_child(struct winbindd_child *child)
        /* Child */
        child_domain = child->domain;
 
-       DEBUG(10, ("Child process %d\n", (int)sys_getpid()));
+       DEBUG(10, ("Child process %d\n", (int)getpid()));
 
        state.sock = fdpair[0];
        close(fdpair[1]);