~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source3/utils/status.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + 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/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 */
32
32
 
33
33
#include "includes.h"
 
34
#include "system/filesys.h"
 
35
#include "popt_common.h"
 
36
#include "dbwrap.h"
 
37
#include "../libcli/security/security.h"
 
38
#include "session.h"
 
39
#include "locking/proto.h"
 
40
#include "messages.h"
34
41
 
35
42
#define SMB_MAXPIDS             2048
36
43
static uid_t            Ucrit_uid = 0;               /* added by OH */
232
239
        TALLOC_FREE(share_mode);
233
240
}
234
241
 
235
 
static int traverse_fn1(struct db_record *rec,
236
 
                        const struct connections_key *key,
 
242
static int traverse_fn1(const struct connections_key *key,
237
243
                        const struct connections_data *crec,
238
244
                        void *state)
239
245
{
252
258
        return 0;
253
259
}
254
260
 
255
 
static int traverse_sessionid(struct db_record *db, void *state)
 
261
static int traverse_sessionid(const char *key, struct sessionid *session,
 
262
                              void *private_data)
256
263
{
257
 
        struct sessionid sessionid;
258
264
        fstring uid_str, gid_str;
259
265
 
260
 
        if (db->value.dsize != sizeof(sessionid))
261
 
                return 0;
262
 
 
263
 
        memcpy(&sessionid, db->value.dptr, sizeof(sessionid));
264
 
 
265
 
        if (!process_exists(sessionid.pid) || !Ucrit_checkUid(sessionid.uid)) {
 
266
        if (!process_exists(session->pid)
 
267
            || !Ucrit_checkUid(session->uid)) {
266
268
                return 0;
267
269
        }
268
270
 
269
 
        Ucrit_addPid( sessionid.pid );
 
271
        Ucrit_addPid(session->pid);
270
272
 
271
 
        fstr_sprintf(uid_str, "%u", (unsigned int)sessionid.uid);
272
 
        fstr_sprintf(gid_str, "%u", (unsigned int)sessionid.gid);
 
273
        fstr_sprintf(uid_str, "%u", (unsigned int)session->uid);
 
274
        fstr_sprintf(gid_str, "%u", (unsigned int)session->gid);
273
275
 
274
276
        d_printf("%-7s   %-12s  %-12s  %-12s (%s)\n",
275
 
                 procid_str_static(&sessionid.pid),
276
 
                 numeric_only ? uid_str : uidtoname(sessionid.uid),
277
 
                 numeric_only ? gid_str : gidtoname(sessionid.gid), 
278
 
                 sessionid.remote_machine, sessionid.hostname);
 
277
                 procid_str_static(&session->pid),
 
278
                 numeric_only ? uid_str : uidtoname(session->uid),
 
279
                 numeric_only ? gid_str : gidtoname(session->gid),
 
280
                 session->remote_machine, session->hostname);
279
281
 
280
282
        return 0;
281
283
}
311
313
        sec_init();
312
314
        load_case_tables();
313
315
 
314
 
        setup_logging(argv[0],True);
315
 
 
316
 
        dbf = x_stderr;
 
316
        setup_logging(argv[0], DEBUG_STDERR);
317
317
 
318
318
        if (getuid() != geteuid()) {
319
319
                d_printf("smbstatus should not be run setuid\n");
412
412
        }
413
413
 
414
414
        if ( show_processes ) {
415
 
                struct db_context *db;
416
 
                db = db_open(NULL, lock_path("sessionid.tdb"), 0,
417
 
                             TDB_CLEAR_IF_FIRST, O_RDONLY, 0644);
418
 
                if (!db) {
419
 
                        d_printf("sessionid.tdb not initialised\n");
420
 
                } else {
421
 
                        d_printf("\nSamba version %s\n",samba_version_string());
422
 
                        d_printf("PID     Username      Group         Machine                        \n");
423
 
                        d_printf("-------------------------------------------------------------------\n");
424
 
                        if (lp_security() == SEC_SHARE) {
425
 
                                d_printf(" <processes do not show up in "
426
 
                                    "anonymous mode>\n");
427
 
                        }
428
 
 
429
 
                        db->traverse_read(db, traverse_sessionid, NULL);
430
 
                        TALLOC_FREE(db);
 
415
                d_printf("\nSamba version %s\n",samba_version_string());
 
416
                d_printf("PID     Username      Group         Machine                        \n");
 
417
                d_printf("-------------------------------------------------------------------\n");
 
418
                if (lp_security() == SEC_SHARE) {
 
419
                        d_printf(" <processes do not show up in "
 
420
                                 "anonymous mode>\n");
431
421
                }
432
422
 
 
423
                sessionid_traverse_read(traverse_sessionid, NULL);
 
424
 
433
425
                if (processes_only) {
434
426
                        goto done;
435
427
                }
447
439
                d_printf("\nService      pid     machine       Connected at\n");
448
440
                d_printf("-------------------------------------------------------\n");
449
441
 
450
 
                connections_forall(traverse_fn1, NULL);
 
442
                connections_forall_read(traverse_fn1, NULL);
451
443
 
452
444
                d_printf("\n");
453
445
 
460
452
                int result;
461
453
                struct db_context *db;
462
454
                db = db_open(NULL, lock_path("locking.tdb"), 0,
463
 
                             TDB_CLEAR_IF_FIRST, O_RDONLY, 0);
 
455
                             TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDONLY, 0);
464
456
 
465
457
                if (!db) {
466
458
                        d_printf("%s not initialised\n",