110-multicall.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --- a/source3/Makefile.in
  2. +++ b/source3/Makefile.in
  3. @@ -73,22 +73,22 @@ LDAP_LIBS=@LDAP_LIBS@
  4. NSCD_LIBS=@NSCD_LIBS@
  5. UUID_LIBS=@UUID_LIBS@
  6. LIBWBCLIENT=@LIBWBCLIENT_STATIC@ @LIBWBCLIENT_SHARED@
  7. -LIBWBCLIENT_LIBS=@LIBWBCLIENT_LIBS@
  8. +LIBWBCLIENT_LIBS=@LIBWBCLIENT_STATIC@
  9. PTHREAD_LDFLAGS=@PTHREAD_LDFLAGS@
  10. PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
  11. DNSSD_LIBS=@DNSSD_LIBS@
  12. AVAHI_LIBS=@AVAHI_LIBS@
  13. POPT_LIBS=@POPTLIBS@
  14. LIBTALLOC=@LIBTALLOC_STATIC@ @LIBTALLOC_SHARED@
  15. -LIBTALLOC_LIBS=@LIBTALLOC_LIBS@
  16. +LIBTALLOC_LIBS=@LIBTALLOC_STATIC@
  17. LIBTEVENT=@LIBTEVENT_STATIC@ @LIBTEVENT_SHARED@
  18. LIBTEVENT_LIBS=@LIBTEVENT_LIBS@
  19. LIBREPLACE_LIBS=@LIBREPLACE_LIBS@
  20. LIBTDB=@LIBTDB_STATIC@ @LIBTDB_SHARED@
  21. -LIBTDB_LIBS=@LIBTDB_LIBS@
  22. +LIBTDB_LIBS=@LIBTDB_STATIC@
  23. TDB_DEPS=@TDB_DEPS@
  24. LIBNETAPI=@LIBNETAPI_STATIC@ @LIBNETAPI_SHARED@
  25. -LIBNETAPI_LIBS=@LIBNETAPI_LIBS@
  26. +LIBNETAPI_LIBS=@LIBNETAPI_STATIC@
  27. LIBSMBCLIENT_LIBS=@LIBSMBCLIENT_LIBS@
  28. LIBSMBSHAREMODES_LIBS=@LIBSMBSHAREMODES_LIBS@
  29. @@ -216,7 +216,7 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_P
  30. # Note that all executable programs now provide for an optional executable suffix.
  31. -SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
  32. +SBIN_PROGS = bin/samba_multicall@EXEEXT@ bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ @SWAT_SBIN_TARGETS@ @EXTRA_SBIN_PROGS@
  33. BIN_PROGS1 = bin/smbclient@EXEEXT@ bin/net@EXEEXT@ bin/smbspool@EXEEXT@ \
  34. bin/testparm@EXEEXT@ bin/smbstatus@EXEEXT@ bin/smbget@EXEEXT@ \
  35. @@ -1799,6 +1799,42 @@ bin/.dummy:
  36. dir=bin $(MAKEDIR); fi
  37. @: >> $@ || : > $@ # what a fancy emoticon!
  38. +smbd/server_multicall.o: smbd/server.c smbd/server.o
  39. + @echo Compiling $<.c
  40. + @$(COMPILE_CC_PATH) -Dmain=smbd_main && exit 0;\
  41. + echo "The following command failed:" 1>&2;\
  42. + echo "$(COMPILE_CC_PATH)" 1>&2;\
  43. + $(COMPILE_CC_PATH) >/dev/null 2>&1
  44. +
  45. +nmbd/nmbd_multicall.o: nmbd/nmbd.c nmbd/nmbd.o
  46. + @echo Compiling $<.c
  47. + @$(COMPILE_CC_PATH) -Dmain=nmbd_main && exit 0;\
  48. + echo "The following command failed:" 1>&2;\
  49. + echo "$(COMPILE_CC_PATH)" 1>&2;\
  50. + $(COMPILE_CC_PATH) >/dev/null 2>&1
  51. +
  52. +utils/smbpasswd_multicall.o: utils/smbpasswd.c utils/smbpasswd.o
  53. + @echo Compiling $<.c
  54. + @$(COMPILE_CC_PATH) -Dmain=smbpasswd_main && exit 0;\
  55. + echo "The following command failed:" 1>&2;\
  56. + echo "$(COMPILE_CC_PATH)" 1>&2;\
  57. + $(COMPILE_CC_PATH) >/dev/null 2>&1
  58. +
  59. +SMBD_MULTI_O = $(patsubst smbd/server.o,smbd/server_multicall.o,$(SMBD_OBJ))
  60. +NMBD_MULTI_O = $(patsubst nmbd/nmbd.o,nmbd/nmbd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(NMBD_OBJ)))
  61. +SMBPASSWD_MULTI_O = $(patsubst utils/smbpasswd.o,utils/smbpasswd_multicall.o,$(filter-out $(LIB_DUMMY_OBJ),$(SMBPASSWD_OBJ)))
  62. +MULTI_O = multi.o
  63. +
  64. +MULTICALL_O = $(sort $(SMBD_MULTI_O) $(NMBD_MULTI_O) $(SMBPASSWD_MULTI_O) $(MULTI_O))
  65. +
  66. +bin/samba_multicall@EXEEXT@: $(BINARY_PREREQS) $(MULTICALL_O) $(LIBTALLOC) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
  67. + @echo Linking $@
  68. + @$(CC) -o $@ $(MULTICALL_O) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
  69. + $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \
  70. + $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) $(AVAHI_LIBS) \
  71. + $(POPT_LIBS) @SMBD_LIBS@ $(LIBTALLOC_LIBS) $(LIBTEVENT_LIBS) $(LIBTDB_LIBS) \
  72. + $(LIBWBCLIENT_LIBS) $(ZLIB_LIBS)
  73. +
  74. bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) $(LIBTALLOC) $(LIBTEVENT) $(LIBTDB) $(LIBWBCLIENT) @BUILD_POPT@
  75. @echo Linking $@
  76. @$(CC) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) @SMBD_FAM_LIBS@ \
  77. --- /dev/null
  78. +++ b/source3/multi.c
  79. @@ -0,0 +1,35 @@
  80. +#include <stdio.h>
  81. +#include <string.h>
  82. +
  83. +extern int smbd_main(int argc, char **argv);
  84. +extern int nmbd_main(int argc, char **argv);
  85. +extern int smbpasswd_main(int argc, char **argv);
  86. +
  87. +static struct {
  88. + const char *name;
  89. + int (*func)(int argc, char **argv);
  90. +} multicall[] = {
  91. + { "smbd", smbd_main },
  92. + { "nmbd", nmbd_main },
  93. + { "smbpasswd", smbpasswd_main },
  94. +};
  95. +
  96. +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
  97. +
  98. +int main(int argc, char **argv)
  99. +{
  100. + int i;
  101. +
  102. + for (i = 0; i < ARRAY_SIZE(multicall); i++) {
  103. + if (strstr(argv[0], multicall[i].name))
  104. + return multicall[i].func(argc, argv);
  105. + }
  106. +
  107. + fprintf(stderr, "Invalid multicall command, available commands:");
  108. + for (i = 0; i < ARRAY_SIZE(multicall); i++)
  109. + fprintf(stderr, " %s", multicall[i].name);
  110. +
  111. + fprintf(stderr, "\n");
  112. +
  113. + return 1;
  114. +}