Hello community,
here is the log from the commit of package nautilus-share
checked in at Fri Jun 9 23:29:28 CEST 2006.
--------
--- GNOME/nautilus-share/nautilus-share.changes 2006-05-03 23:42:01.000000000 +0200
+++ nautilus-share/nautilus-share.changes 2006-06-09 18:48:41.000000000 +0200
@@ -1,0 +2,8 @@
+Fri Jun 9 18:48:25 CEST 2006 - federico@novell.com
+
+- Added nautilus-share-181811-guest-permissions.diff to fix bug
+ https://bugzilla.novell.com/show_bug.cgi?id=181811. This will add
+ the "guest_ok=y" option to the "net usershare" command line, as well
+ as adding group permissions to the shared folder if appropriate.
+
+-------------------------------------------------------------------
New:
----
nautilus-share-181811-guest-permissions.diff
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ nautilus-share.spec ++++++
--- /var/tmp/diff_new_pack.jjUZ7z/_old 2006-06-09 23:29:23.000000000 +0200
+++ /var/tmp/diff_new_pack.jjUZ7z/_new 2006-06-09 23:29:23.000000000 +0200
@@ -13,7 +13,7 @@
Name: nautilus-share
BuildRequires: eel-devel gnome-patch-translation gnutls-devel intltool libgnomeprintui-devel libwnck-devel mDNSResponder-devel nautilus-devel perl-XML-Parser update-desktop-files
Version: 0.6.4
-Release: 30
+Release: 32
URL: http://gentoo.ovibes.net/nautilus-share/
Group: Productivity/Networking/Samba
License: GPL
@@ -23,6 +23,7 @@
Patch1: nautilus-share-net-usershare.diff
Patch2: nautilus-share-potfiles.patch
Patch3: nautilus-share-170212-restore-modified-permissions.diff
+Patch4: nautilus-share-181811-guest-permissions.diff
Requires: gnome-icon-theme samba >= 3.0.21a-4.2
Autoreqprov: on
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -64,6 +65,7 @@
%patch
%patch1 -p0
%patch3 -p1
+%patch4 -p1
# NOTE: You can ignore iter.* uninitialized warnings in nautilus-share.c:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197
gnome-patch-translation-update
@@ -94,6 +96,11 @@
/opt/gnome/share/nautilus-share
%changelog -n nautilus-share
+* Fri Jun 09 2006 - federico@novell.com
+- Added nautilus-share-181811-guest-permissions.diff to fix bug
+ https://bugzilla.novell.com/show_bug.cgi?id=181811. This will add
+ the "guest_ok=y" option to the "net usershare" command line, as well
+ as adding group permissions to the shared folder if appropriate.
* Wed May 03 2006 - federico@novell.com
- Added nautilus-share-170212-restore-modified-permissions.diff to fix
https://bugzilla.novell.com/show_bug.cgi?id=170212. We now restore
++++++ nautilus-share-181811-guest-permissions.diff ++++++
2006-06-08 Federico Mena Quintero
Fix https://bugzilla.novell.com/show_bug.cgi?id=181811:
* src/shares.c (samba_configuration_supports_guest_ok): New
function. Calls "testparm -s --parameter-name='usershare allow
guests'" to see if Samba is configured to support "guest_ok=y"
when calling "net usershare".
(add_share): Call samba_configuration_supports_guest_ok(), and
then add "guest_ok=y" to the "net usershare" command line if
appropriate.
* src/nautilus-share.c (confirm_sharing_permissions): For
read-only usershares, we need go+rx permissions on the shared
folder. For writable usershares, we also need go+w. Check the
group permissions instead of just the other ones.
(message_confirm_missing_permissions): Check the group permissions
as well as the other permissions.
(save_changed_permissions): Save the mask of needed permissions in
a single key, instead of using three separate keys for r/w/x.
(remove_permissions): Use a mask of needed permissions rather than
individual flags.
(restore_saved_permissions): Likewise. Also, read the octal
string that was saved in save_changed_permissions().
--- nautilus-share/src/nautilus-share.c 8 Jun 2006 23:35:33 -0000 1.18
+++ nautilus-share/src/nautilus-share.c 9 Jun 2006 01:23:14 -0000
@@ -187,8 +187,7 @@ property_page_validate_fields (PropertyP
}
static gboolean
-message_confirm_missing_permissions (GtkWidget *widget, const char *path,
- gboolean need_r, gboolean need_w, gboolean need_x)
+message_confirm_missing_permissions (GtkWidget *widget, const char *path, mode_t need_mask)
{
GtkWidget *toplevel;
GtkWidget *dialog;
@@ -208,14 +207,18 @@ message_confirm_missing_permissions (Gtk
_("Nautilus needs to add some permissions to your folder \"%s\" in order to share it"),
display_name);
+ /* FIXME: the following message only mentions "permission by others". We
+ * should probably be more explicit and mention group/other permissions.
+ * We'll be able to do that after the period of string freeze.
+ */
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("The folder \"%s\" needs the following extra permissions for sharing to work:\n"
"%s%s%s"
"Do you want Nautilus to add these permissions to the folder automatically?"),
display_name,
- need_r ? _(" - read permission by others\n") : "",
- need_w ? _(" - write permission by others\n") : "",
- need_x ? _(" - execute permission by others\n") : "");
+ (need_mask & (S_IRGRP | S_IROTH)) ? _(" - read permission by others\n") : "",
+ (need_mask & (S_IWGRP | S_IWOTH)) ? _(" - write permission by others\n") : "",
+ (need_mask & (S_IXGRP | S_IXOTH)) ? _(" - execute permission by others\n") : "");
g_free (display_name);
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
@@ -277,10 +280,11 @@ save_key_file (const char *filename, GKe
}
static void
-save_changed_permissions (const char *path, gboolean need_r, gboolean need_w, gboolean need_x)
+save_changed_permissions (const char *path, mode_t need_mask)
{
GKeyFile *key_file;
char *key_file_path;
+ char str[50];
key_file = g_key_file_new ();
key_file_path = get_key_file_path ();
@@ -292,9 +296,8 @@ save_changed_permissions (const char *pa
*/
g_key_file_load_from_file (key_file, key_file_path, 0, NULL);
- g_key_file_set_boolean (key_file, path, "need_r", need_r);
- g_key_file_set_boolean (key_file, path, "need_w", need_w);
- g_key_file_set_boolean (key_file, path, "need_x", need_x);
+ g_snprintf (str, sizeof (str), "%o", (guint) need_mask); /* octal, baby */
+ g_key_file_set_string (key_file, path, "need_mask", str);
save_key_file (key_file_path, key_file);
@@ -303,27 +306,18 @@ save_changed_permissions (const char *pa
}
static void
-remove_permissions (const char *path, gboolean need_r, gboolean need_w, gboolean need_x)
+remove_permissions (const char *path, mode_t need_mask)
{
struct stat st;
mode_t new_mode;
- if (!need_r && !need_w && !need_x)
+ if (need_mask == 0)
return;
if (stat (path, &st) != 0)
return;
- new_mode = st.st_mode;
-
- if (need_r)
- new_mode &= ~S_IROTH;
-
- if (need_w)
- new_mode &= ~S_IWOTH;
-
- if (need_x)
- new_mode &= ~S_IXOTH;
+ new_mode = st.st_mode & ~need_mask;
/* Bleah, no error checking */
chmod (path, new_mode);
@@ -343,14 +337,24 @@ restore_saved_permissions (const char *p
if (g_key_file_has_group (key_file, path))
{
- gboolean need_r, need_w, need_x;
+ char *str;
/* NULL GError */
- need_r = g_key_file_get_boolean (key_file, path, "need_r", NULL);
- need_w = g_key_file_get_boolean (key_file, path, "need_w", NULL);
- need_x = g_key_file_get_boolean (key_file, path, "need_x", NULL);
+ str = g_key_file_get_string (key_file, path, "need_mask", NULL);
+
+ if (str)
+ {
+ guint i;
+ mode_t need_mask;
+
+ if (sscanf (str, "%o", &i) == 1) /* octal */
+ {
+ need_mask = i;
+ remove_permissions (path, need_mask);
+ }
- remove_permissions (path, need_r, need_w, need_x);
+ g_free (str);
+ }
/* NULL GError */
g_key_file_remove_group (key_file, path, NULL);
@@ -374,10 +378,7 @@ static ConfirmPermissionsStatus
confirm_sharing_permissions (GtkWidget *widget, const char *path, gboolean is_shared, gboolean is_writable)
{
struct stat st;
- mode_t mode, new_mode;
- gboolean need_r;
- gboolean need_w;
- gboolean need_x;
+ mode_t mode, new_mode, need_mask;
if (!is_shared)
return CONFIRM_NO_MODIFICATIONS;
@@ -386,21 +387,18 @@ confirm_sharing_permissions (GtkWidget *
return CONFIRM_NO_MODIFICATIONS; /* We'll just let "net usershare" give back an error if the file disappears */
mode = st.st_mode;
- new_mode = mode;
+ new_mode = mode | (S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); /* ... add go+rx */
- need_r = (mode & S_IROTH) == 0;
- new_mode |= S_IROTH;
+ if (is_writable)
+ new_mode |= S_IWGRP | S_IWOTH; /* ... add go+w */
- need_w = is_writable && (mode & S_IWOTH) == 0;
- if (need_w)
- new_mode |= S_IWOTH;
+ need_mask = new_mode & ~mode;
- need_x = (mode & S_IXOTH) == 0;
- new_mode |= S_IXOTH;
-
- if (need_r || need_w || need_x)
+ if (need_mask != 0)
{
- if (!message_confirm_missing_permissions (widget, path, need_r, need_w, need_x))
+ g_assert (mode != new_mode);
+
+ if (!message_confirm_missing_permissions (widget, path, need_mask))
return CONFIRM_CANCEL_OR_ERROR;
if (chmod (path, new_mode) != 0)
@@ -409,12 +407,15 @@ confirm_sharing_permissions (GtkWidget *
return CONFIRM_CANCEL_OR_ERROR;
}
- save_changed_permissions (path, need_r, need_w, need_x);
+ save_changed_permissions (path, need_mask);
return CONFIRM_MODIFIED;
}
else
- return CONFIRM_NO_MODIFICATIONS;
+ {
+ g_assert (mode == new_mode);
+ return CONFIRM_NO_MODIFICATIONS;
+ }
g_assert_not_reached ();
return CONFIRM_CANCEL_OR_ERROR;
--- nautilus-share/src/shares.c 20 Feb 2006 17:18:48 -0000 1.18
+++ nautilus-share/src/shares.c 9 Jun 2006 00:20:12 -0000
@@ -480,12 +480,93 @@ copy_share_info (ShareInfo *info)
}
static gboolean
+samba_configuration_supports_guest_ok (gboolean *supports_guest_ok_ret, GError **error)
+{
+ gboolean retval;
+ gboolean result;
+ char *stdout_contents;
+ char *stderr_contents;
+ int exit_status;
+ int exit_code;
+
+ *supports_guest_ok_ret = FALSE;
+
+ result = g_spawn_command_line_sync ("testparm -s --parameter-name='usershare allow guests'",
+ &stdout_contents,
+ &stderr_contents,
+ &exit_status,
+ error);
+ if (!result)
+ return FALSE;
+
+ retval = FALSE;
+
+ if (!WIFEXITED (exit_status)) {
+ if (WIFSIGNALED (exit_status)) {
+ int signal_num;
+
+ signal_num = WTERMSIG (exit_status);
+ g_set_error (error,
+ SHARES_ERROR,
+ SHARES_ERROR_FAILED,
+ _("Samba's testparm returned with signal %d"),
+ signal_num);
+ } else
+ g_set_error (error,
+ SHARES_ERROR,
+ SHARES_ERROR_FAILED,
+ _("Samba's testparm failed for an unknown reason"));
+
+ goto out;
+ }
+
+ exit_code = WEXITSTATUS (exit_status);
+ if (exit_code != 0) {
+ char *str;
+ char *message;
+
+ /* stderr_contents is in the system locale encoding, not UTF-8 */
+
+ str = g_locale_to_utf8 (stderr_contents, -1, NULL, NULL, NULL);
+
+ if (str && str[0])
+ message = g_strdup_printf (_("Samba's testparm returned error %d: %s"), exit_code, str);
+ else
+ message = g_strdup_printf (_("Samba's testparm returned error %d"), exit_code);
+
+ g_free (str);
+
+ g_set_error (error,
+ G_SPAWN_ERROR,
+ G_SPAWN_ERROR_FAILED,
+ "%s",
+ message);
+
+ g_free (message);
+
+ goto out;
+ }
+
+ retval = TRUE;
+ *supports_guest_ok_ret = (g_ascii_strncasecmp (stdout_contents, "Yes", 3) == 0);
+
+ out:
+ g_free (stdout_contents);
+ g_free (stderr_contents);
+
+ return retval;
+}
+
+static gboolean
add_share (ShareInfo *info, GError **error)
{
- char *argv[6];
+ char *argv[7];
+ int argc;
ShareInfo *copy;
GKeyFile *key_file;
GError *real_error;
+ gboolean supports_success;
+ gboolean supports_guest_ok;
g_message ("add_share() start");
@@ -498,6 +579,10 @@ add_share (ShareInfo *info, GError **err
return FALSE;
}
+ supports_success = samba_configuration_supports_guest_ok (&supports_guest_ok, error);
+ if (!supports_success)
+ return FALSE;
+
argv[0] = "add";
argv[1] = "-l";
argv[2] = info->share_name;
@@ -505,8 +590,14 @@ add_share (ShareInfo *info, GError **err
argv[4] = info->comment;
argv[5] = info->is_writable ? "Everyone:F" : "Everyone:R";
+ if (supports_guest_ok) {
+ argv[6] = "guest_ok=y";
+ argc = 7;
+ } else
+ argc = 6;
+
real_error = NULL;
- if (!net_usershare_run (G_N_ELEMENTS (argv), argv, &key_file, &real_error)) {
+ if (!net_usershare_run (argc, argv, &key_file, &real_error)) {
g_message ("Called \"net usershare add\" but it failed: %s", real_error->message);
g_propagate_error (error, real_error);
return FALSE;
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit-unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit-help@opensuse.org