Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorAndrew Tridgell <tridge@samba.org>
Tue, 31 Mar 2009 02:59:56 +0000 (13:59 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 31 Mar 2009 02:59:56 +0000 (13:59 +1100)
docs-xml/smbdotconf/printing/cupsencrypt.xml [new file with mode: 0644]
source3/configure.in
source3/include/proto.h
source3/param/loadparm.c
source3/printing/print_cups.c
source3/smbd/dosmode.c

diff --git a/docs-xml/smbdotconf/printing/cupsencrypt.xml b/docs-xml/smbdotconf/printing/cupsencrypt.xml
new file mode 100644 (file)
index 0000000..f93b1c5
--- /dev/null
@@ -0,0 +1,25 @@
+<samba:parameter name="cups encrypt"
+       context="G"
+       type="enum"
+       advanced="1" print="1"
+       xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+       <para>
+       This parameter is only applicable if <smbconfoption name="printing"/>
+       is set to <constant>cups</constant> and if you use CUPS newer than
+       1.0.x.It is used to define whether or not Samba should use encryption
+       when talking to the CUPS server. Possible values are
+       <emphasis>auto</emphasis>, <emphasis>yes</emphasis> and
+       <emphasis>no</emphasis>
+       </para>
+
+       <para>
+       When set to auto we will try to do a TLS handshake on each CUPS
+       connection setup. If that fails, we will fall back to unencrypted
+       operation.
+       </para>
+
+</description>
+
+<value type="default">"no"</value>
+</samba:parameter>
index 1cf8d9ca4a45d1b73fe750e053b872e977fb7748..0850bf5a7f29d0cf637dbb7da16ca583085ae108 100644 (file)
@@ -788,6 +788,7 @@ if test x$enable_cups != xno; then
                        x"$ac_cv_header_cups_language_h" = xyes; then
                        AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
                        samba_cv_HAVE_CUPS=yes
+                       AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
                else
                        AC_MSG_WARN([cups-config around but cups-devel not installed])
                        CFLAGS=$ac_save_CFLAGS
index 77be0aba09008d892033e01b21431d2f91c4df52..2e76764e018532617c5c9b0861d840ce837ffcda 100644 (file)
@@ -4125,6 +4125,7 @@ const char **lp_admin_users(int );
 const char **lp_svcctl_list(void);
 char *lp_cups_options(int );
 char *lp_cups_server(void);
+int lp_cups_encrypt(void);
 char *lp_iprint_server(void);
 int lp_cups_connection_timeout(void);
 const char *lp_ctdbd_socket(void);
index 66fb8bf1bc603f0c98da1983caf2472b36bb3afc..8da1f6348fb4a11b6fa6ace86057468ff950b3c1 100644 (file)
 #include "includes.h"
 #include "printing.h"
 
+#ifdef HAVE_HTTPCONNECTENCRYPT
+#include <cups/http.h>
+#endif
+
 bool bLoaded = False;
 
 extern enum protocol_types Protocol;
@@ -257,6 +261,7 @@ struct global {
        int ldap_debug_threshold;
        int iAclCompat;
        char *szCupsServer;
+       int CupsEncrypt;
        char *szIPrintServer;
        char *ctdbdSocket;
        char **szClusterAddresses;
@@ -774,6 +779,8 @@ static const struct enum_list enum_case[] = {
        {-1, NULL}
 };
 
+
+
 static const struct enum_list enum_bool_auto[] = {
        {False, "No"},
        {False, "False"},
@@ -2628,6 +2635,16 @@ static struct parm_struct parm_table[] = {
                .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
        },
        {
+               .label          = "cups encrypt",
+               .type           = P_ENUM,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.CupsEncrypt,
+               .special        = NULL,
+               .enum_list      = enum_bool_auto,
+               .flags          = FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
+       },
+       {
+
                .label          = "cups connection timeout",
                .type           = P_INTEGER,
                .p_class        = P_GLOBAL,
@@ -5471,6 +5488,23 @@ FN_LOCAL_LIST(lp_admin_users, szAdminUsers)
 FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
+int lp_cups_encrypt(void)
+{
+#ifdef HAVE_HTTPCONNECTENCRYPT
+       switch (Globals.CupsEncrypt) {
+               case Auto:
+                       Globals.CupsEncrypt = HTTP_ENCRYPT_REQUIRED;
+                       break;
+               case True:
+                       Globals.CupsEncrypt = HTTP_ENCRYPT_ALWAYS;
+                       break;
+               case False:
+                       Globals.CupsEncrypt = HTTP_ENCRYPT_NEVER;
+                       break;
+       }
+#endif
+       return Globals.CupsEncrypt;
+}
 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
 FN_GLOBAL_INTEGER(lp_cups_connection_timeout, &Globals.cups_connection_timeout)
 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
index 8e792a944a3b3283c8c8d8eae043f78f07de6140..7edfb5edbeb61cc49288286ce3b6c0075823e162 100644 (file)
@@ -93,7 +93,12 @@ static http_t *cups_connect(TALLOC_CTX *frame)
                 alarm(timeout);
         }
 
+#ifdef HAVE_HTTPCONNECTENCRYPT
+       http = httpConnectEncrypt(server, port, lp_cups_encrypt());
+#else
        http = httpConnect(server, port);
+#endif
+
 
        CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
         alarm(0);
index 555718bd83a02f2760365e3c83984003fc25326e..5ae715130335d4a5117740c6450c11cce722c14c 100644 (file)
@@ -325,8 +325,10 @@ uint32 dos_mode_msdfs(connection_struct *conn, const char *path,SMB_STRUCT_STAT
                } else {
                        p = path;
                }
-               
-               if (p[0] == '.' && p[1] != '.' && p[1] != 0) {
+
+               /* Only . and .. are not hidden. */
+               if (p[0] == '.' && !((p[1] == '\0') ||
+                               (p[1] == '.' && p[2] == '\0'))) {
                        result |= aHIDDEN;
                }
        }
@@ -484,8 +486,10 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
                } else {
                        p = path;
                }
-               
-               if (p[0] == '.' && p[1] != '.' && p[1] != 0) {
+
+               /* Only . and .. are not hidden. */
+               if (p[0] == '.' && !((p[1] == '\0') ||
+                               (p[1] == '.' && p[2] == '\0'))) {
                        result |= aHIDDEN;
                }
        }