mirror of
https://github.com/samba-team/samba.git
synced 2025-08-05 12:22:11 +03:00
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.
This commit is contained in:
@ -439,7 +439,7 @@ static BOOL dfs_auth(char *user, char *password)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
|
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
|
||||||
user, getpid()));
|
user, sys_getpid()));
|
||||||
|
|
||||||
DEBUG(3, ("DCE principal: %s\n"
|
DEBUG(3, ("DCE principal: %s\n"
|
||||||
" uid: %d\n"
|
" uid: %d\n"
|
||||||
@ -487,7 +487,7 @@ void dfs_unlogin(void)
|
|||||||
dce_error_inq_text(err, dce_errstr, &err2);
|
dce_error_inq_text(err, dce_errstr, &err2);
|
||||||
DEBUG(0,
|
DEBUG(0,
|
||||||
("DCE purge login context failed for server instance %d: %s\n",
|
("DCE purge login context failed for server instance %d: %s\n",
|
||||||
getpid(), dce_errstr));
|
sys_getpid(), dce_errstr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -595,7 +595,7 @@ static BOOL krb4_auth(char *user, char *password)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
|
(void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
|
||||||
(int)getpid());
|
(int)sys_getpid());
|
||||||
|
|
||||||
krb_set_tkt_string(tkfile);
|
krb_set_tkt_string(tkfile);
|
||||||
if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
|
if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
|
||||||
|
@ -849,7 +849,7 @@ static void cmd_more(void)
|
|||||||
fstrcat(rname,"\\");
|
fstrcat(rname,"\\");
|
||||||
slprintf(tmpname,
|
slprintf(tmpname,
|
||||||
sizeof(fstring)-1,
|
sizeof(fstring)-1,
|
||||||
"%s/smbmore.%d",tmpdir(),(int)getpid());
|
"%s/smbmore.%d",tmpdir(),(int)sys_getpid());
|
||||||
fstrcpy(lname,tmpname);
|
fstrcpy(lname,tmpname);
|
||||||
|
|
||||||
if (!next_token(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
|
if (!next_token(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
|
||||||
@ -1159,7 +1159,7 @@ static void cmd_mput(void)
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
slprintf(tmpname,sizeof(pstring)-1,
|
slprintf(tmpname,sizeof(pstring)-1,
|
||||||
"%s/ls.smb.%d",tmpdir(),(int)getpid());
|
"%s/ls.smb.%d",tmpdir(),(int)sys_getpid());
|
||||||
if (recurse)
|
if (recurse)
|
||||||
slprintf(cmd,sizeof(pstring)-1,
|
slprintf(cmd,sizeof(pstring)-1,
|
||||||
"find . -name \"%s\" -print > %s",p,tmpname);
|
"find . -name \"%s\" -print > %s",p,tmpname);
|
||||||
@ -1269,11 +1269,11 @@ static void cmd_print(void)
|
|||||||
pstrcpy(rname,lname);
|
pstrcpy(rname,lname);
|
||||||
p = strrchr(rname,'/');
|
p = strrchr(rname,'/');
|
||||||
if (p) {
|
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,"-")) {
|
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);
|
do_put(rname, lname);
|
||||||
|
@ -72,7 +72,7 @@ static void daemonize(void)
|
|||||||
|
|
||||||
signal( SIGTERM, exit_parent );
|
signal( SIGTERM, exit_parent );
|
||||||
|
|
||||||
if ((child_pid = fork()) < 0) {
|
if ((child_pid = sys_fork()) < 0) {
|
||||||
fprintf(stderr,"could not fork\n");
|
fprintf(stderr,"could not fork\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ static void init_mount(void)
|
|||||||
args[i++] = xstrdup(tmp);
|
args[i++] = xstrdup(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fork() == 0) {
|
if (sys_fork() == 0) {
|
||||||
if (file_exist(BINDIR "/smbmnt", NULL)) {
|
if (file_exist(BINDIR "/smbmnt", NULL)) {
|
||||||
execv(BINDIR "/smbmnt", args);
|
execv(BINDIR "/smbmnt", args);
|
||||||
fprintf(stderr,"execv of %s failed. Error was %s.", BINDIR "/smbmnt", strerror(errno));
|
fprintf(stderr,"execv of %s failed. Error was %s.", BINDIR "/smbmnt", strerror(errno));
|
||||||
|
@ -246,6 +246,8 @@ DIR *wsys_opendir(const smb_ucs2_t *wfname);
|
|||||||
smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
|
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_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
|
||||||
int wsys_chroot(const smb_ucs2_t *wfname);
|
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_popen(const char *command);
|
||||||
int sys_pclose(int fd);
|
int sys_pclose(int fd);
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ BOOL dbghdr( int level, char *file, char *func, int line )
|
|||||||
header_str[0] = '\0';
|
header_str[0] = '\0';
|
||||||
|
|
||||||
if( lp_debug_pid())
|
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()) {
|
if( lp_debug_uid()) {
|
||||||
size_t hs_len = strlen(header_str);
|
size_t hs_len = strlen(header_str);
|
||||||
|
@ -38,7 +38,7 @@ static void fault_report(int sig)
|
|||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
DEBUG(0,("===============================================================\n"));
|
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,("\nPlease read the file BUGS.txt in the distribution\n"));
|
||||||
DEBUG(0,("===============================================================\n"));
|
DEBUG(0,("===============================================================\n"));
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ static uint32 do_reseed(unsigned char *md4_outbuf)
|
|||||||
* Finally add the counter, time of day, and pid.
|
* Finally add the counter, time of day, and pid.
|
||||||
*/
|
*/
|
||||||
GetTimeOfDay(&tval);
|
GetTimeOfDay(&tval);
|
||||||
mypid = getpid();
|
mypid = sys_getpid();
|
||||||
v1 = (counter++) + mypid + tval.tv_sec;
|
v1 = (counter++) + mypid + tval.tv_sec;
|
||||||
v2 = (counter++) * mypid + tval.tv_usec;
|
v2 = (counter++) * mypid + tval.tv_usec;
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
matching routine!
|
matching routine!
|
||||||
|
|
||||||
NOTE: this matches only filenames with no directory component
|
NOTE: this matches only filenames with no directory component
|
||||||
|
|
||||||
|
Returns 0 on match, -1 on fail.
|
||||||
*/
|
*/
|
||||||
int ms_fnmatch(char *pattern, char *string)
|
int ms_fnmatch(char *pattern, char *string)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ void pidfile_create(char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
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)) {
|
if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
|
||||||
DEBUG(0,("ERROR: can't write to file %s: %s\n",
|
DEBUG(0,("ERROR: can't write to file %s: %s\n",
|
||||||
pidFile, strerror(errno)));
|
pidFile, strerror(errno)));
|
||||||
|
@ -124,7 +124,7 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
|
|||||||
|
|
||||||
CatchChildLeaveStatus();
|
CatchChildLeaveStatus();
|
||||||
|
|
||||||
if ((pid=fork()) < 0) {
|
if ((pid=sys_fork()) < 0) {
|
||||||
DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
|
DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
|
||||||
CatchChild();
|
CatchChild();
|
||||||
return errno;
|
return errno;
|
||||||
|
@ -176,7 +176,7 @@ void standard_sub_basic(char *str)
|
|||||||
case 'T' : string_sub(p,"%T", timestring(False),l); break;
|
case 'T' : string_sub(p,"%T", timestring(False),l); break;
|
||||||
case 'a' : string_sub(p,"%a", remote_arch,l); break;
|
case 'a' : string_sub(p,"%a", remote_arch,l); break;
|
||||||
case 'd' :
|
case 'd' :
|
||||||
slprintf(pidstr,sizeof(pidstr), "%d",(int)getpid());
|
slprintf(pidstr,sizeof(pidstr), "%d",(int)sys_getpid());
|
||||||
string_sub(p,"%d", pidstr,l);
|
string_sub(p,"%d", pidstr,l);
|
||||||
break;
|
break;
|
||||||
case 'h' : string_sub(p,"%h", myhostname(),l); break;
|
case 'h' : string_sub(p,"%h", myhostname(),l); break;
|
||||||
|
@ -932,11 +932,41 @@ static char **extract_args(const char *command)
|
|||||||
return argl;
|
return argl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
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.
|
Wrapper for popen. Safer as it doesn't search a path.
|
||||||
Modified from the glibc sources.
|
Modified from the glibc sources.
|
||||||
modified by tridge to return a file descriptor. We must kick our FILE* habit
|
modified by tridge to return a file descriptor. We must kick our FILE* habit
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
typedef struct _popen_list
|
typedef struct _popen_list
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@ -974,7 +1004,7 @@ int sys_popen(const char *command)
|
|||||||
if(!(argl = extract_args(command)))
|
if(!(argl = extract_args(command)))
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
|
||||||
entry->child_pid = fork();
|
entry->child_pid = sys_fork();
|
||||||
|
|
||||||
if (entry->child_pid == -1) {
|
if (entry->child_pid == -1) {
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
|
@ -741,7 +741,7 @@ become a daemon, discarding the controlling terminal
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void become_daemon(void)
|
void become_daemon(void)
|
||||||
{
|
{
|
||||||
if (fork()) {
|
if (sys_fork()) {
|
||||||
_exit(0);
|
_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) &&
|
if ((ret != -1) &&
|
||||||
(lock.l_type != F_UNLCK) &&
|
(lock.l_type != F_UNLCK) &&
|
||||||
(lock.l_pid != 0) &&
|
(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));
|
DEBUG(3,("fd %d is locked by pid %d\n",fd,(int)lock.l_pid));
|
||||||
return(True);
|
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];
|
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'";
|
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);
|
pstring_sub(cmd, "%d", pidstr);
|
||||||
|
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
|
@ -172,7 +172,7 @@ struct cli_state *cli_initialise(struct cli_state *cli)
|
|||||||
cli->port = 0;
|
cli->port = 0;
|
||||||
cli->fd = -1;
|
cli->fd = -1;
|
||||||
cli->cnum = -1;
|
cli->cnum = -1;
|
||||||
cli->pid = (uint16)getpid();
|
cli->pid = (uint16)sys_getpid();
|
||||||
cli->mid = 1;
|
cli->mid = 1;
|
||||||
cli->vuid = UID_FIELD_INVALID;
|
cli->vuid = UID_FIELD_INVALID;
|
||||||
cli->protocol = PROTOCOL_NT1;
|
cli->protocol = PROTOCOL_NT1;
|
||||||
|
@ -35,7 +35,7 @@ static int generate_trn_id(void)
|
|||||||
static int trn_id;
|
static int trn_id;
|
||||||
|
|
||||||
if (trn_id == 0) {
|
if (trn_id == 0) {
|
||||||
srandom(getpid());
|
srandom(sys_getpid());
|
||||||
}
|
}
|
||||||
|
|
||||||
trn_id = random();
|
trn_id = random();
|
||||||
|
@ -69,7 +69,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn,
|
|||||||
return(False);
|
return(False);
|
||||||
|
|
||||||
ret = !brl_locktest(fsp->dev, fsp->inode,
|
ret = !brl_locktest(fsp->dev, fsp->inode,
|
||||||
global_smbpid, getpid(), conn->cnum,
|
global_smbpid, sys_getpid(), conn->cnum,
|
||||||
offset, count, lock_type);
|
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)) {
|
if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) {
|
||||||
ok = brl_lock(fsp->dev, fsp->inode, fsp->fnum,
|
ok = brl_lock(fsp->dev, fsp->inode, fsp->fnum,
|
||||||
global_smbpid, getpid(), conn->cnum,
|
global_smbpid, sys_getpid(), conn->cnum,
|
||||||
offset, count,
|
offset, count,
|
||||||
lock_type);
|
lock_type);
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn,
|
|||||||
* lock entry.
|
* lock entry.
|
||||||
*/
|
*/
|
||||||
(void)brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
|
(void)brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
|
||||||
global_smbpid, getpid(), conn->cnum,
|
global_smbpid, sys_getpid(), conn->cnum,
|
||||||
offset, count);
|
offset, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ok = brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
|
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) {
|
if (!ok) {
|
||||||
DEBUG(10,("do_unlock: returning ERRlock.\n" ));
|
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)
|
void locking_close_file(files_struct *fsp)
|
||||||
{
|
{
|
||||||
pid_t pid = getpid();
|
pid_t pid = sys_getpid();
|
||||||
|
|
||||||
if (!lp_locking(SNUM(fsp->conn)))
|
if (!lp_locking(SNUM(fsp->conn)))
|
||||||
return;
|
return;
|
||||||
@ -337,7 +337,7 @@ void del_share_mode(files_struct *fsp)
|
|||||||
struct locking_data *data;
|
struct locking_data *data;
|
||||||
int i, del_count=0;
|
int i, del_count=0;
|
||||||
share_mode_entry *shares;
|
share_mode_entry *shares;
|
||||||
pid_t pid = getpid();
|
pid_t pid = sys_getpid();
|
||||||
|
|
||||||
/* read in the existing share modes */
|
/* read in the existing share modes */
|
||||||
dbuf = tdb_fetch(tdb, locking_key_fsp(fsp));
|
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)
|
static void fill_share_mode(char *p, files_struct *fsp, uint16 port, uint16 op_type)
|
||||||
{
|
{
|
||||||
share_mode_entry *e = (share_mode_entry *)p;
|
share_mode_entry *e = (share_mode_entry *)p;
|
||||||
e->pid = getpid();
|
e->pid = sys_getpid();
|
||||||
e->share_mode = fsp->share_mode;
|
e->share_mode = fsp->share_mode;
|
||||||
e->op_port = port;
|
e->op_port = port;
|
||||||
e->op_type = op_type;
|
e->op_type = op_type;
|
||||||
@ -453,7 +453,7 @@ static BOOL mod_share_mode(files_struct *fsp,
|
|||||||
struct locking_data *data;
|
struct locking_data *data;
|
||||||
int i;
|
int i;
|
||||||
share_mode_entry *shares;
|
share_mode_entry *shares;
|
||||||
pid_t pid = getpid();
|
pid_t pid = sys_getpid();
|
||||||
int need_store=0;
|
int need_store=0;
|
||||||
|
|
||||||
/* read in the existing share modes */
|
/* read in the existing share modes */
|
||||||
|
@ -140,7 +140,7 @@ void start_async_dns(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
child_pid = fork();
|
child_pid = sys_fork();
|
||||||
|
|
||||||
if (child_pid) {
|
if (child_pid) {
|
||||||
fd_in = fd1[0];
|
fd_in = fd1[0];
|
||||||
|
@ -652,7 +652,7 @@ static void usage(char *pname)
|
|||||||
|
|
||||||
StartupTime = time(NULL);
|
StartupTime = time(NULL);
|
||||||
|
|
||||||
sys_srandom(time(NULL) ^ getpid());
|
sys_srandom(time(NULL) ^ sys_getpid());
|
||||||
|
|
||||||
TimeInit();
|
TimeInit();
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ static uint16 generate_name_trn_id(void)
|
|||||||
|
|
||||||
if (!name_trn_id)
|
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;
|
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
|
||||||
return name_trn_id;
|
return name_trn_id;
|
||||||
|
@ -153,7 +153,7 @@ void sync_browse_lists(struct work_record *work,
|
|||||||
/* the parent forks and returns, leaving the child to do the
|
/* the parent forks and returns, leaving the child to do the
|
||||||
actual sync */
|
actual sync */
|
||||||
CatchChild();
|
CatchChild();
|
||||||
if ((s->pid = fork())) return;
|
if ((s->pid = sys_fork())) return;
|
||||||
|
|
||||||
BlockSignals( False, SIGTERM );
|
BlockSignals( False, SIGTERM );
|
||||||
|
|
||||||
|
@ -1592,14 +1592,14 @@ void wins_write_database(BOOL background)
|
|||||||
doesn't block while this is done */
|
doesn't block while this is done */
|
||||||
if (background) {
|
if (background) {
|
||||||
CatchChild();
|
CatchChild();
|
||||||
if (fork()) {
|
if (sys_fork()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slprintf(fname,sizeof(fname),"%s/%s", lp_lockdir(), WINS_LIST);
|
slprintf(fname,sizeof(fname),"%s/%s", lp_lockdir(), WINS_LIST);
|
||||||
all_string_sub(fname,"//", "/", 0);
|
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)
|
if((fp = sys_fopen(fnamenew,"w")) == NULL)
|
||||||
{
|
{
|
||||||
|
@ -439,7 +439,7 @@ static BOOL dfs_auth(char *user, char *password)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
|
DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
|
||||||
user, getpid()));
|
user, sys_getpid()));
|
||||||
|
|
||||||
DEBUG(3, ("DCE principal: %s\n"
|
DEBUG(3, ("DCE principal: %s\n"
|
||||||
" uid: %d\n"
|
" uid: %d\n"
|
||||||
@ -487,7 +487,7 @@ void dfs_unlogin(void)
|
|||||||
dce_error_inq_text(err, dce_errstr, &err2);
|
dce_error_inq_text(err, dce_errstr, &err2);
|
||||||
DEBUG(0,
|
DEBUG(0,
|
||||||
("DCE purge login context failed for server instance %d: %s\n",
|
("DCE purge login context failed for server instance %d: %s\n",
|
||||||
getpid(), dce_errstr));
|
sys_getpid(), dce_errstr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -595,7 +595,7 @@ static BOOL krb4_auth(char *user, char *password)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
|
(void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
|
||||||
(int)getpid());
|
(int)sys_getpid());
|
||||||
|
|
||||||
krb_set_tkt_string(tkfile);
|
krb_set_tkt_string(tkfile);
|
||||||
if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
|
if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
|
||||||
|
@ -1106,7 +1106,7 @@ static BOOL del_smbfilepwd_entry(const char *name)
|
|||||||
FILE *fp_write = NULL;
|
FILE *fp_write = NULL;
|
||||||
int pfile2_lockdepth = 0;
|
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
|
* Open the smbpassword file - for update. It needs to be update
|
||||||
|
@ -67,12 +67,12 @@ Does not survive a fork
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
BOOL print_backend_init(void)
|
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);
|
tdb = tdb_open(lock_path("printing.tdb"), 0, 0, O_RDWR|O_CREAT, 0600);
|
||||||
if (!tdb) {
|
if (!tdb) {
|
||||||
DEBUG(0,("Failed to open printing backend database\n"));
|
DEBUG(0,("Failed to open printing backend database\n"));
|
||||||
}
|
}
|
||||||
local_pid = getpid();
|
local_pid = sys_getpid();
|
||||||
|
|
||||||
/* handle a Samba upgrade */
|
/* handle a Samba upgrade */
|
||||||
tdb_writelock(tdb);
|
tdb_writelock(tdb);
|
||||||
|
@ -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, 4 , pol_hnd_low ); /* second bit is incrementing */
|
||||||
SIVAL(hnd->data, 8 , pol_hnd_high); /* 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, 12, time(NULL)); /* something random */
|
||||||
SIVAL(hnd->data, 16, getpid()); /* something more random */
|
SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -144,7 +144,7 @@ static void attempt_remote_rpc_connect(pipes_struct *p)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
become_root(False); /* to connect to pipe */
|
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);
|
unbecome_root(False);
|
||||||
|
|
||||||
if (p->m == NULL)
|
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
|
log files and prevents client bugs where pipe numbers are reused
|
||||||
over connection restarts */
|
over connection restarts */
|
||||||
if (next_pipe == 0)
|
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);
|
i = bitmap_find(bmap, next_pipe);
|
||||||
|
|
||||||
|
@ -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, 4 , prt_hnd_low ); /* second bit is incrementing */
|
||||||
SIVAL(hnd->data, 8 , prt_hnd_high); /* 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, 12, time(NULL)); /* something random */
|
||||||
SIVAL(hnd->data, 16, getpid()); /* something more random */
|
SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -330,7 +330,7 @@ static BOOL chat_with_program(char *passwordprogram, char *name,
|
|||||||
|
|
||||||
CatchChildLeaveStatus();
|
CatchChildLeaveStatus();
|
||||||
|
|
||||||
if ((pid = fork()) < 0)
|
if ((pid = sys_fork()) < 0)
|
||||||
{
|
{
|
||||||
DEBUG(3,
|
DEBUG(3,
|
||||||
("Cannot fork() child for password change: %s\n",
|
("Cannot fork() child for password change: %s\n",
|
||||||
|
@ -45,7 +45,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
|
|||||||
DEBUG(3,("Yielding connection to %s\n",name));
|
DEBUG(3,("Yielding connection to %s\n",name));
|
||||||
|
|
||||||
ZERO_STRUCT(key);
|
ZERO_STRUCT(key);
|
||||||
key.pid = getpid();
|
key.pid = sys_getpid();
|
||||||
if (conn) key.cnum = conn->cnum;
|
if (conn) key.cnum = conn->cnum;
|
||||||
fstrcpy(key.name, name);
|
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));
|
DEBUG(5,("claiming %s %d\n",name,max_connections));
|
||||||
|
|
||||||
ZERO_STRUCT(key);
|
ZERO_STRUCT(key);
|
||||||
key.pid = getpid();
|
key.pid = sys_getpid();
|
||||||
key.cnum = conn?conn->cnum:-1;
|
key.cnum = conn?conn->cnum:-1;
|
||||||
fstrcpy(key.name, name);
|
fstrcpy(key.name, name);
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
|
|||||||
/* fill in the crec */
|
/* fill in the crec */
|
||||||
ZERO_STRUCT(crec);
|
ZERO_STRUCT(crec);
|
||||||
crec.magic = 0x280267;
|
crec.magic = 0x280267;
|
||||||
crec.pid = getpid();
|
crec.pid = sys_getpid();
|
||||||
crec.cnum = conn?conn->cnum:-1;
|
crec.cnum = conn?conn->cnum:-1;
|
||||||
if (conn) {
|
if (conn) {
|
||||||
crec.uid = conn->uid;
|
crec.uid = conn->uid;
|
||||||
|
@ -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)) {
|
if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type)) {
|
||||||
share_mode_entry *share_list = NULL;
|
share_mode_entry *share_list = NULL;
|
||||||
pid_t pid = getpid();
|
pid_t pid = sys_getpid();
|
||||||
int token = -1;
|
int token = -1;
|
||||||
int num_share_modes = 0;
|
int num_share_modes = 0;
|
||||||
int i;
|
int i;
|
||||||
|
@ -55,7 +55,7 @@ files_struct *file_new(void )
|
|||||||
increases the chance that the errant client will get an error rather
|
increases the chance that the errant client will get an error rather
|
||||||
than causing corruption */
|
than causing corruption */
|
||||||
if (first_file == 0) {
|
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);
|
i = bitmap_find(file_bmap, first_file);
|
||||||
|
@ -87,7 +87,7 @@ static int reply_lanman1(char *outbuf)
|
|||||||
SSVAL(outbuf,smb_vwv4,1);
|
SSVAL(outbuf,smb_vwv4,1);
|
||||||
SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
|
SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
|
||||||
readbraw writebraw (possibly) */
|
readbraw writebraw (possibly) */
|
||||||
SIVAL(outbuf,smb_vwv6,getpid());
|
SIVAL(outbuf,smb_vwv6,sys_getpid());
|
||||||
SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
|
SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
|
||||||
|
|
||||||
put_dos_date(outbuf,smb_vwv8,t);
|
put_dos_date(outbuf,smb_vwv8,t);
|
||||||
@ -133,7 +133,7 @@ static int reply_lanman2(char *outbuf)
|
|||||||
|
|
||||||
set_message(outbuf,13,crypt_len,True);
|
set_message(outbuf,13,crypt_len,True);
|
||||||
SSVAL(outbuf,smb_vwv1,secword);
|
SSVAL(outbuf,smb_vwv1,secword);
|
||||||
SIVAL(outbuf,smb_vwv6,getpid());
|
SIVAL(outbuf,smb_vwv6,sys_getpid());
|
||||||
if (doencrypt)
|
if (doencrypt)
|
||||||
memcpy(smb_buf(outbuf), cryptkey, 8);
|
memcpy(smb_buf(outbuf), cryptkey, 8);
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ static int reply_nt1(char *outbuf)
|
|||||||
SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
|
SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
|
||||||
SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
|
SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
|
||||||
SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
|
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 */
|
SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
|
||||||
put_long_date(outbuf+smb_vwv11+1,t);
|
put_long_date(outbuf+smb_vwv11+1,t);
|
||||||
SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
|
SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
|
||||||
|
@ -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,
|
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) ||
|
if ((access_allowed == AFAIL) ||
|
||||||
(!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
|
(!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;
|
share_mode_entry *old_shares = 0;
|
||||||
int num_share_modes;
|
int num_share_modes;
|
||||||
SMB_STRUCT_STAT sbuf;
|
SMB_STRUCT_STAT sbuf;
|
||||||
pid_t pid = getpid();
|
pid_t pid = sys_getpid();
|
||||||
SMB_DEV_T dev;
|
SMB_DEV_T dev;
|
||||||
SMB_INO_T inode;
|
SMB_INO_T inode;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ address %lx. Error was %s\n", (long)htonl(INADDR_LOOPBACK), strerror(errno)));
|
|||||||
return False;
|
return False;
|
||||||
|
|
||||||
DEBUG(3,("open_oplock ipc: pid = %d, global_oplock_port = %u\n",
|
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;
|
return True;
|
||||||
}
|
}
|
||||||
@ -1088,7 +1088,7 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
|
|||||||
{
|
{
|
||||||
char op_break_msg[OPLOCK_BREAK_MSG_LEN];
|
char op_break_msg[OPLOCK_BREAK_MSG_LEN];
|
||||||
struct sockaddr_in addr_out;
|
struct sockaddr_in addr_out;
|
||||||
pid_t pid = getpid();
|
pid_t pid = sys_getpid();
|
||||||
time_t start_time;
|
time_t start_time;
|
||||||
int time_left;
|
int time_left;
|
||||||
long usec;
|
long usec;
|
||||||
@ -1342,7 +1342,7 @@ void check_kernel_oplocks(void)
|
|||||||
set_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
|
set_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
|
||||||
set_inherited_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) {
|
if(pipe(pfd) != 0) {
|
||||||
DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n",
|
DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n",
|
||||||
|
@ -53,8 +53,8 @@ void generate_next_challenge(char *challenge)
|
|||||||
|
|
||||||
/* get a sort-of random number */
|
/* get a sort-of random number */
|
||||||
GetTimeOfDay(&tval);
|
GetTimeOfDay(&tval);
|
||||||
v1 = (counter++) + getpid() + tval.tv_sec;
|
v1 = (counter++) + sys_getpid() + tval.tv_sec;
|
||||||
v2 = (counter++) * getpid() + tval.tv_usec;
|
v2 = (counter++) * sys_getpid() + tval.tv_usec;
|
||||||
SIVAL(challenge,0,v1);
|
SIVAL(challenge,0,v1);
|
||||||
SIVAL(challenge,4,v2);
|
SIVAL(challenge,4,v2);
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
|
|||||||
extern int global_smbpid;
|
extern int global_smbpid;
|
||||||
|
|
||||||
if (pid == (pid_t)-1)
|
if (pid == (pid_t)-1)
|
||||||
pid = getpid();
|
pid = sys_getpid();
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
last_message = type;
|
last_message = type;
|
||||||
|
@ -238,7 +238,7 @@ max can be %d\n",
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smbd_server_fd() != -1 && fork()==0) {
|
if (smbd_server_fd() != -1 && sys_fork()==0) {
|
||||||
/* Child code ... */
|
/* Child code ... */
|
||||||
|
|
||||||
/* close the listening socket(s) */
|
/* close the listening socket(s) */
|
||||||
|
@ -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( "connect to service %s ", lp_servicename(SNUM(conn)) );
|
||||||
dbgtext( "as user %s ", user );
|
dbgtext( "as user %s ", user );
|
||||||
dbgtext( "(uid=%d, gid=%d) ", (int)geteuid(), (int)getegid() );
|
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 */
|
/* we've finished with the sensitive stuff */
|
||||||
|
Reference in New Issue
Block a user