~ubuntu-branches/ubuntu/natty/nautilus-share/natty

« back to all changes in this revision

Viewing changes to src/shares.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-03-21 20:11:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090321201102-25223q0d2znoighn
Tags: 0.7.2-4
* debian/patches/06_fix-validation.patch:
  + Fix issue where field validation errors aren't cleared after being
    corrected
* debian/patches/02_install_missing_samba.patch:
  + Ask to retry if installation failed

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#define KEY_PATH "path"
25
25
#define KEY_COMMENT "comment"
26
26
#define KEY_ACL "usershare_acl"
 
27
#define KEY_GUEST_OK "guest_ok"
 
28
#define GROUP_ALLOW_GUESTS "global"
 
29
#define KEY_ALLOW_GUESTS "usershare allow guests"
27
30
 
28
31
/* Debugging flags */
29
32
static gboolean throw_error_on_refresh;
322
325
        char *comment;
323
326
        char *acl;
324
327
        gboolean is_writable;
 
328
        char *guest_ok_str;
 
329
        gboolean guest_ok;
325
330
        ShareInfo *info;
326
331
        ShareInfo *old_info;
327
332
 
369
374
                is_writable = FALSE;
370
375
        }
371
376
 
 
377
        guest_ok_str = get_string_from_key_file (key_file, group, KEY_GUEST_OK);
 
378
        if (guest_ok_str) {
 
379
                if (strcmp (guest_ok_str, "n") == 0)
 
380
                        guest_ok = FALSE;
 
381
                else if (strcmp (guest_ok_str, "y") == 0)
 
382
                        guest_ok = TRUE;
 
383
                else {
 
384
                        g_message ("unknown format for key '%s/%s' as it contains '%s'.  Assuming that the share is not guest accessible.",
 
385
                                   group, KEY_GUEST_OK, guest_ok_str);
 
386
                        guest_ok = FALSE;
 
387
                }
 
388
 
 
389
                g_free (guest_ok_str);
 
390
        } else {
 
391
                g_message ("group '%s' doesn't have a '%s' key!  Assuming that the share is not guest accessible.", group, KEY_GUEST_OK);
 
392
                guest_ok = FALSE;
 
393
        }
 
394
 
372
395
        g_assert (path != NULL);
373
396
        g_assert (group != NULL);
374
397
 
377
400
        info->share_name = g_strdup (group);
378
401
        info->comment = comment;
379
402
        info->is_writable = is_writable;
 
403
        info->guest_ok = guest_ok;
380
404
 
381
405
        add_share_info_to_hashes (info);
382
406
}
475
499
        copy->share_name = g_strdup (info->share_name);
476
500
        copy->comment = g_strdup (info->comment);
477
501
        copy->is_writable = info->is_writable;
 
502
        copy->guest_ok = info->guest_ok;
478
503
 
479
504
        return copy;
480
505
}
481
506
 
482
 
static gboolean
483
 
samba_configuration_supports_guest_ok (gboolean *supports_guest_ok_ret, GError **error)
 
507
/**
 
508
 * shares_supports_guest_ok:
 
509
 * @supports_guest_ok_ret: Location to store whether "usershare allow guests"
 
510
 * is enabled.
 
511
 * @error: Location to store error, or #NULL.
 
512
 *
 
513
 * Determines whether the option "usershare allow guests" is enabled in samba
 
514
 * config as shown by testparm.
 
515
 *
 
516
 * Return value: #TRUE if if the info could be queried successfully, #FALSE
 
517
 * otherwise.  If this function returns #FALSE, an error code will be returned
 
518
 * in the @error argument, and *@ret_info_list will be set to #FALSE.
 
519
 **/
 
520
gboolean
 
521
shares_supports_guest_ok (gboolean *supports_guest_ok_ret, GError **error)
484
522
{
485
523
        gboolean retval;
486
524
        gboolean result;
579
617
                return FALSE;
580
618
        }
581
619
 
582
 
        supports_success = samba_configuration_supports_guest_ok (&supports_guest_ok, error);
 
620
        supports_success = shares_supports_guest_ok (&supports_guest_ok, error);
583
621
        if (!supports_success)
584
622
                return FALSE;
585
623
 
591
629
        argv[5] = info->is_writable ? "Everyone:F" : "Everyone:R";
592
630
 
593
631
        if (supports_guest_ok) {
594
 
                argv[6] = "guest_ok=y";
 
632
                argv[6] = info->guest_ok ? "guest_ok=y" : "guest_ok=n";
595
633
                argc = 7;
596
634
        } else
597
635
                argc = 6;