~ubuntu-branches/ubuntu/maverick/samba/maverick-security

« back to all changes in this revision

Viewing changes to source/lib/ctdbd_conn.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-03-03 22:02:23 UTC
  • mfrom: (0.28.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090303220223-3bdlm2d9fwx1p1ye
Tags: 2:3.3.1-1ubuntu1
* Merge from Debian unstable (LP: #337094), remaining changes:
  + debian/patches/VERSION.patch:
    - setup SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access. 
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/mksambapasswd.awk:
    - Do not add user with UID less than 1000 to smbpasswd.
  + debian/control:
    - Make libwbclient0 replace/conflict with hardy's likewise-open.
    - Don't build against ctdb.
  + debian/rules:
    - enable "native" PIE hardening.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
* Dropped changes, merged in Debian:
  + debian/libpam-smbpass.pam-config, debian/libpam-smbpass.postinst,
    debian/libpam-smbpass.prerm, debian/libpam-smbpass.files,
    debian/rules:
    - Make libpam-smbpasswd depend on libpam-runtime to allow 
      libpam-smbpasswd for auto-configuration.
  + debian/control:
    - Provide a config block for the new PAM framework to auto-configure
      itself
  + debian/samba.postinst:
    - When populating the new sambashare group, it is not an error
      if the user simply does not exist; test for this case and let
      the install continue instead of aborting.
  + debian/winbind.files:
    - include additional files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1170
1170
}
1171
1171
 
1172
1172
/*
 
1173
   This is used to canonicalize a ctdb_sock_addr structure.
 
1174
*/
 
1175
static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in,
 
1176
                                      struct sockaddr_storage *out)
 
1177
{
 
1178
        memcpy(out, in, sizeof (*out));
 
1179
 
 
1180
#ifdef HAVE_IPV6
 
1181
        if (in->ss_family == AF_INET6) {
 
1182
                const char prefix[12] = { 0,0,0,0,0,0,0,0,0,0,0xff,0xff };
 
1183
                const struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)in;
 
1184
                struct sockaddr_in *out4 = (struct sockaddr_in *)out;
 
1185
                if (memcmp(&in6->sin6_addr, prefix, 12) == 0) {
 
1186
                        memset(out, 0, sizeof(*out));
 
1187
#ifdef HAVE_SOCK_SIN_LEN
 
1188
                        out4->sin_len = sizeof(*out);
 
1189
#endif
 
1190
                        out4->sin_family = AF_INET;
 
1191
                        out4->sin_port   = in6->sin6_port;
 
1192
                        memcpy(&out4->sin_addr, &in6->sin6_addr.s6_addr32[3], 4);
 
1193
                }
 
1194
        }
 
1195
#endif
 
1196
}
 
1197
 
 
1198
/*
1173
1199
 * Register us as a server for a particular tcp connection
1174
1200
 */
1175
1201
 
1176
1202
NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
1177
 
                            const struct sockaddr_storage *server,
1178
 
                            const struct sockaddr_storage *client,
 
1203
                            const struct sockaddr_storage *_server,
 
1204
                            const struct sockaddr_storage *_client,
1179
1205
                            void (*release_ip_handler)(const char *ip_addr,
1180
1206
                                                       void *private_data),
1181
1207
                            void *private_data)
1182
1208
{
1183
 
        struct sockaddr *sock = (struct sockaddr *)client;
1184
1209
        /*
1185
1210
         * we still use ctdb_control_tcp for ipv4
1186
1211
         * because we want to work against older ctdb
1187
1212
         * versions at runtime
1188
1213
         */
1189
1214
        struct ctdb_control_tcp p4;
1190
 
#ifdef HAVE_IPV6
 
1215
#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
1191
1216
        struct ctdb_control_tcp_addr p;
1192
1217
#endif
1193
1218
        TDB_DATA data;
1194
1219
        NTSTATUS status;
 
1220
        struct sockaddr_storage client;
 
1221
        struct sockaddr_storage server;
1195
1222
 
1196
1223
        /*
1197
1224
         * Only one connection so far
1198
1225
         */
1199
1226
        SMB_ASSERT(conn->release_ip_handler == NULL);
1200
1227
 
1201
 
        switch (sock->sa_family) {
 
1228
        smbd_ctdb_canonicalize_ip(_client, &client);
 
1229
        smbd_ctdb_canonicalize_ip(_server, &server);
 
1230
 
 
1231
        switch (client.ss_family) {
1202
1232
        case AF_INET:
1203
 
                p4.dest = *(struct sockaddr_in *)server;
1204
 
                p4.src = *(struct sockaddr_in *)client;
 
1233
                p4.dest = *(struct sockaddr_in *)&server;
 
1234
                p4.src = *(struct sockaddr_in *)&client;
1205
1235
                data.dptr = (uint8_t *)&p4;
1206
1236
                data.dsize = sizeof(p4);
1207
1237
                break;
1208
 
#ifdef HAVE_IPV6
 
1238
#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
1209
1239
        case AF_INET6:
1210
 
                p.dest.ip6 = *(struct sockaddr_in6 *)server;
1211
 
                p.src.ip6 = *(struct sockaddr_in6 *)client;
 
1240
                p.dest.ip6 = *(struct sockaddr_in6 *)&server;
 
1241
                p.src.ip6 = *(struct sockaddr_in6 *)&client;
1212
1242
                data.dptr = (uint8_t *)&p;
1213
1243
                data.dsize = sizeof(p);
1214
1244
                break;