Dan Langille schrieb:

>> Folks: If you happen to upgrade to 1.38.6 and you start getting
>> permission
>> errors on your tape drive, when it worked in previous versions, a
>> work around
>> may be changing the group for bacula-sd.
>>
>> For me, in FreeBSD, I add this to /etc/rc.conf:
>>
>> bacula_sd_flags=" -u bacula -g operator -v -c /usr/local/etc/bacula-
>> sd.conf"
>>
>> In short, I'm running as the group specified on /dev/sa0
>>
>> # ls -l /dev/sa0
>> crw-rw----  4 root  operator   14,   0 Mar 13  2005 /dev/sa0
>>
>> And not as the group bacula, of which bacula is a member:
>>
>> # id bacula
>> uid=910(bacula) gid=910(bacula) groups=910(bacula), 5(operator)
>>
>> I'm trying to find the cause of this problem.

Hi,

I've had similar problem a while ago and submitted a possible solution
(patch attached) but Kerns wasn't quite satisfied with it. The followup
is here:
http://sourceforge.net/mailarchive/forum.php?thread_id=9644823&forum_id=8650
It was made for the 1.38.5 but should apply to the the 1.38.6 as well. I
haven't got around yet to check it against the current release, but I
think it should go without problems.

If you get time to apply it, share your results. The current state is
WorksForMe (tm).

Regards,
-Dimitri aka Tristan-777

--- bacula-1.38.5/src/lib/bsys.c	2005-12-22 22:35:24.000000000 +0100
+++ bacula-1.38.5-mod/src/lib/bsys.c	2006-02-05 23:37:03.000000000 +0100
@@ -602,30 +602,36 @@
  */
 void drop(char *uid, char *gid)
 {
-#ifdef HAVE_GRP_H
-   if (gid) {
-      struct group *group;
-      gid_t gr_list[1];
-
-      if ((group = getgrnam(gid)) == NULL) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not find specified group: %s\n"), gid);
-      }
-      if (setgid(group->gr_gid)) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
-      }
-      gr_list[0] = group->gr_gid;
-      if (setgroups(1, gr_list)) {
-         Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
-      }
-   }
-#endif
 
 #ifdef HAVE_PWD_H
    if (uid) {
       struct passwd *passw;
+      struct group  *group;
+      gid_t gr_gid;
+      
       if ((passw = getpwnam(uid)) == NULL) {
          Emsg1(M_ERROR_TERM, 0, _("Could not find specified userid: %s\n"), uid);
       }
+      
+#ifdef HAVE_GRP_H
+      gr_gid = passw->pw_gid;
+
+      if (gid) {
+         if ((group = getgrnam(gid)) == NULL) {
+            Emsg1(M_ERROR_TERM, 0, _("Could not find specified group: %s\n"), gid);
+         }
+	 gr_gid = group->gr_gid;
+      }
+
+      if (setgid(gr_gid)) {
+         Emsg1(M_ERROR_TERM, 0, _("Could not set specified group: %s\n"), gid);
+      }
+
+      if (initgroups(passw->pw_name, gr_gid)) {
+          Emsg1(M_ERROR_TERM, 0, _("Could not setup group access for user: %s\n"), uid);
+      }
+#endif
+      
       if (setuid(passw->pw_uid)) {
          Emsg1(M_ERROR_TERM, 0, _("Could not set specified userid: %s\n"), uid);
       }

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to