Move source4/smbd/pidfile into lib/util in preparation for making it in common.
authorJeremy Allison <jra@samba.org>
Thu, 19 Jul 2012 22:41:52 +0000 (15:41 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 19 Jul 2012 22:41:52 +0000 (15:41 -0700)
15 files changed:
lib/util/pidfile.c [moved from source4/smbd/pidfile.c with 99% similarity]
lib/util/pidfile.h [new file with mode: 0644]
lib/util/wscript_build
source3/include/proto.h
source3/lib/pidfile.c
source3/libsmb/clidgram.c
source3/nmbd/nmbd.c
source3/smbd/server.c
source3/smbd/server_exit.c
source3/utils/smbcontrol.c
source3/web/startstop.c
source3/web/statuspage.c
source3/winbindd/winbindd.c
source4/smbd/server.c
source4/smbd/wscript_build

similarity index 99%
rename from source4/smbd/pidfile.c
rename to lib/util/pidfile.c
index 32d3964302ecfe0ccf10e35ee876264b9e727001..ac8ff8a0c3fde0f9a139a3a4c4111e983232c30f 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "system/filesys.h"
-#include "smbd/pidfile.h"
+#include "lib/util/pidfile.h"
 
 /**
  * @file
diff --git a/lib/util/pidfile.h b/lib/util/pidfile.h
new file mode 100644 (file)
index 0000000..92a277d
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Jeremy Allison 2012.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SAMBA_PIDFILE_H_
+#define _SAMBA_PIDFILE_H_
+
+pid_t pidfile_pid(const char *piddir, const char *name);
+void pidfile_create(const char *piddir, const char *program_name);
+
+#endif
index 340cf12cd4f0dedf312172203a04ce6232e600c0..ddaf90ffc28f1bcf128c995fe9ebf5a0d2824ccf 100755 (executable)
@@ -7,7 +7,7 @@ bld.SAMBA_LIBRARY('samba-util',
                     signal.c system.c params.c util.c util_id.c util_net.c
                     util_strlist.c util_paths.c idtree.c debug.c fault.c base64.c
                     util_str.c util_str_common.c substitute.c ms_fnmatch.c
-                    server_id.c dprintf.c parmlist.c bitmap.c''',
+                    server_id.c dprintf.c parmlist.c bitmap.c pidfile.c''',
                   deps='DYNCONFIG',
                   public_deps='talloc execinfo uid_wrapper pthread LIBCRYPTO charset util_setid',
                   public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h',
index 4d99a607e35bb08b80cae176ccc98d7091e3ef95..b58f9a294567f3f8a0d6ec5199b7ec282c8267ca 100644 (file)
@@ -160,9 +160,9 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
 
 /* The following definitions come from lib/pidfile.c  */
 
-pid_t pidfile_pid(const char *name);
-void pidfile_create(const char *program_name);
-void pidfile_unlink(void);
+pid_t pidfile_pid_s3(const char *name);
+void pidfile_create_s3(const char *program_name);
+void pidfile_unlink_s3(void);
 
 /* The following definitions come from lib/recvfile.c  */
 
index 987ab068e753ecb433ae8ccf87d0949cc7a03db4..1170f876c386dc63bb52d194f509aee70caf4986 100644 (file)
@@ -30,7 +30,7 @@ static char *pidFile_name = NULL;
 
 /* return the pid in a pidfile. return 0 if the process (or pidfile)
    does not exist */
-pid_t pidfile_pid(const char *program_name)
+pid_t pidfile_pid_s3(const char *program_name)
 {
        int fd;
        char pidstr[20];
@@ -115,7 +115,7 @@ pid_t pidfile_pid(const char *program_name)
 }
 
 /* create a pid file in the pid directory. open it and leave it locked */
-void pidfile_create(const char *program_name)
+void pidfile_create_s3(const char *program_name)
 {
        int     fd;
        char    buf[20];
@@ -146,7 +146,7 @@ void pidfile_create(const char *program_name)
                smb_panic("asprintf failed");
        }
 
-       pid = pidfile_pid(program_name);
+       pid = pidfile_pid_s3(program_name);
        if (pid != 0) {
                DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n", 
                         name, pidFile_name, (int)pid));
@@ -181,7 +181,7 @@ void pidfile_create(const char *program_name)
        fcntl(fd, F_SETFD, FD_CLOEXEC);
 }
 
-void pidfile_unlink(void)
+void pidfile_unlink_s3(void)
 {
        if (pidFile_name == NULL) {
                return;
index 377219448bc3a12b10c36bbd50199460c53e1a1b..d9de99eb0439c62a7cad5f2ab5ec3e66e2162514 100644 (file)
@@ -327,7 +327,7 @@ struct tevent_req *nbt_getdc_send(TALLOC_CTX *mem_ctx,
        if (tevent_req_nomem(state->my_mailslot, req)) {
                return tevent_req_post(req, ev);
        }
-       state->nmbd_pid = pidfile_pid("nmbd");
+       state->nmbd_pid = pidfile_pid_s3("nmbd");
        if (state->nmbd_pid == 0) {
                DEBUG(3, ("No nmbd found\n"));
                tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
index ebe83a614763f96e65cbf7ad94033a01007704aa..35ed3c0d92aae12c6c9b4a12ff58c78fb1d95da9 100644 (file)
@@ -70,7 +70,7 @@ static void terminate(struct messaging_context *msg)
        gencache_stabilize();
        serverid_deregister(messaging_server_id(msg));
 
-       pidfile_unlink();
+       pidfile_unlink_s3();
 
        exit(0);
 }
@@ -942,7 +942,7 @@ static bool open_sockets(bool isdaemon, int port)
                mkdir(lp_piddir(), 0755);
        }
 
-       pidfile_create("nmbd");
+       pidfile_create_s3("nmbd");
 
        status = reinit_after_fork(msg, nmbd_event_context(),
                                   false);
index f7f1d8c7156d676317cdd3f40dbd5e134a1d557d..ee1eafb0dc5b52b93cd1f772953cd43e39a8fca4 100644 (file)
@@ -1285,7 +1285,7 @@ extern void build_options(bool screen);
                mkdir(lp_piddir(), 0755);
 
        if (is_daemon)
-               pidfile_create("smbd");
+               pidfile_create_s3("smbd");
 
        status = reinit_after_fork(msg_ctx,
                                   ev_ctx,
index 07b8432bff75ad9b46724c82c275b1864ca0f776..86a621f551a3e41b21d0e2f73f02a23838588d6d 100644 (file)
@@ -216,7 +216,7 @@ static void exit_server_common(enum server_exit_reason how,
                DEBUG(3,("Server exit (%s)\n",
                        (reason ? reason : "normal exit")));
                if (am_parent) {
-                       pidfile_unlink();
+                       pidfile_unlink_s3();
                }
                gencache_stabilize();
        }
index 54e10d8b42fa76c6719955576feea9626dba7243..dbbd8049de833efbe6020351c2f09a72c38fe21e 100644 (file)
@@ -1365,7 +1365,7 @@ static struct server_id parse_dest(struct messaging_context *msg,
 
        /* Look up other destinations in pidfile directory */
 
-       if ((pid = pidfile_pid(dest)) != 0) {
+       if ((pid = pidfile_pid_s3(dest)) != 0) {
                return pid_to_procid(pid);
        }
 
index e23acf8931376fc9d54c2d5c8d07f9667158df2f..ef2871ccd3a5378f79bbf33acf95867d7b37f142 100644 (file)
@@ -86,7 +86,7 @@ void start_winbindd(void)
 /* stop smbd */
 void stop_smbd(void)
 {
-       pid_t pid = pidfile_pid("smbd");
+       pid_t pid = pidfile_pid_s3("smbd");
 
        if (geteuid() != 0) return;
 
@@ -98,7 +98,7 @@ void stop_smbd(void)
 /* stop nmbd */
 void stop_nmbd(void)
 {
-       pid_t pid = pidfile_pid("nmbd");
+       pid_t pid = pidfile_pid_s3("nmbd");
 
        if (geteuid() != 0) return;
 
@@ -110,7 +110,7 @@ void stop_nmbd(void)
 /* stop winbindd */
 void stop_winbindd(void)
 {
-       pid_t pid = pidfile_pid("winbindd");
+       pid_t pid = pidfile_pid_s3("winbindd");
 
        if (geteuid() != 0) return;
 
index 8eac8036d024538b8ca4591225f614dbac41e9ed..d04554901c562e21f6da05d2c24aab705df1f165 100644 (file)
@@ -253,7 +253,7 @@ void status_page(void)
        TALLOC_CTX *ctx = talloc_stackframe();
        const char form_name[] = "status";
 
-       smbd_pid = pid_to_procid(pidfile_pid("smbd"));
+       smbd_pid = pid_to_procid(pidfile_pid_s3("smbd"));
 
        if (!verify_xsrf_token(form_name)) {
                goto output_page;
index fe6e34b4b99a7a9cf1417d90d410793282025ef9..dfbcf13eb4b300fe3d432fc50a89f4da3f8f5030 100644 (file)
@@ -184,7 +184,7 @@ static void terminate(bool is_parent)
 
        if (is_parent) {
                serverid_deregister(procid_self());
-               pidfile_unlink();
+               pidfile_unlink_s3();
        }
 
        exit(0);
@@ -1449,7 +1449,7 @@ int main(int argc, char **argv, char **envp)
        if (!interactive)
                become_daemon(Fork, no_process_group, log_stdout);
 
-       pidfile_create("winbindd");
+       pidfile_create_s3("winbindd");
 
 #if HAVE_SETPGID
        /*
index 21560f981f801ec864179c8bdb568da9d82d1877..a6ebcd65d8b46614d2958124ee3cda7d7f8478ab 100644 (file)
@@ -34,7 +34,7 @@
 #include "libcli/auth/schannel.h"
 #include "smbd/process_model.h"
 #include "param/secrets.h"
-#include "smbd/pidfile.h"
+#include "lib/util/pidfile.h"
 #include "param/param.h"
 #include "dsdb/samdb/samdb.h"
 #include "auth/session.h"
index 97877fc54b09e15ed486ebe0922e6e074a0043b8..bfa13121f283ca00c0b3b7298f1b692b1054be3b 100644 (file)
@@ -9,12 +9,6 @@ bld.SAMBA_LIBRARY('service',
        )
 
 
-bld.SAMBA_SUBSYSTEM('PIDFILE',
-       source='pidfile.c',
-       deps='talloc',
-       autoproto='pidfile.h'
-       )
-
 bld.SAMBA_LIBRARY('process_model',
                   source='process_model.c',
                   autoproto='process_model_proto.h',
@@ -27,7 +21,7 @@ bld.SAMBA_BINARY('samba',
        source='server.c',
        manpages='samba.8',
        subsystem_name='service',
-       deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA PIDFILE
+       deps='''events process_model service samba-hostconfig samba-util POPT_SAMBA
                 popt gensec registry ntptr ntvfs share cluster COMMON_SCHANNEL SECRETS''',
        pyembed=True,
        install_path='${SBINDIR}',