Group :: Networking/Other
RPM: nbd
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: nbd-alt.patch
Download
Download
diff --git a/Makefile.am b/Makefile.am
index 4fcfd63..0e39fea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ libnbdsrv_la_SOURCES = nbdsrv.c nbdsrv.h treefiles.c treefiles.h
libnbdsrv_la_CFLAGS = @CFLAGS@ @GLIB_CFLAGS@
client_libs = libcliserv.la
nbd_server_LDADD = @GLIB_LIBS@ libnbdsrv.la libcliserv.la
+nbd_server_LDADD += @SETPROCTITLE_LIBS@
nbd_trdump_LDADD = libcliserv.la
make_integrityhuge_SOURCES = make-integrityhuge.c cliserv.h nbd.h nbd-debug.h
EXTRA_DIST = maketr CodingStyle autogen.sh README.md support/genver.sh
diff --git a/configure.ac b/configure.ac
index 05ee827..71558b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -279,6 +279,30 @@ AM_CONDITIONAL(CLIENT, [test ! -z "$NBD_CLIENT_NAME"])
AC_SEARCH_LIBS(bind, socket,, AC_MSG_ERROR([Could not find an implementation of the bind() system call]))
AC_SEARCH_LIBS(inet_ntoa, nsl,, AC_MSG_ERROR([Could not find an implementation of the inet_ntoa() system call]))
AC_SEARCH_LIBS(daemon, resolv,, AC_MSG_ERROR([Could not find an implementation of the daemon() system call]))
+
+AC_ARG_WITH([setproctitle],
+ [AC_HELP_STRING([--with-setproctitle],
+ [Use setproctitle in nbd-server (default is no)])],
+ [use_setproctitle=$withval],
+ [use_setproctitle=no]
+ )
+SETPROCTITLE_LIBS=
+AC_MSG_CHECKING([whether to use setproctitle in nbd-server])
+AS_IF([test "x$use_setproctitle" = xyes],
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE([USE_SETPROCTITLE], [1],
+ [Define to 1 if you want nbd-server to use setproctitle])
+ AC_CHECK_HEADERS([setproctitle.h])
+ AC_SEARCH_LIBS([setproctitle],,,
+ [AC_CHECK_LIB([setproctitle], [setproctitle],
+ [SETPROCTITLE_LIBS="-lsetproctitle"],
+ [AC_MSG_ERROR([setproctitle not found])])]
+ )
+ ],
+ [AC_MSG_RESULT([no])]
+ )
+AC_SUBST([SETPROCTITLE_LIBS])
+
AC_CHECK_HEADERS([sys/mount.h],,,
[[#include <sys/param.h>
]])
diff --git a/nbd-server.c b/nbd-server.c
index 0b32bcd..a27d018 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -143,6 +143,12 @@
#include <winioctl.h>
#endif
+#if USE_SETPROCTITLE
+# ifdef HAVE_SETPROCTITLE_H
+# include <setproctitle.h>
+# endif
+#endif
+
/** Default position of the config file */
#ifndef SYSCONFDIR
#define SYSCONFDIR "/etc"
@@ -2946,7 +2952,10 @@ handle_modern_connection(GArray *const servers, const int sock, struct generic_c
g_array_free(servers, FALSE);
}
- msg(LOG_INFO, "Starting to serve");
+ msg(LOG_INFO, "Starting to serve %s for %s", client->exportname, client->clientname);
+#if USE_SETPROCTITLE
+ setproctitle("%s", client->clientname);
+#endif
mainloop_threaded(client);
exit(EXIT_SUCCESS);