PDA

View Full Version : Problems with Subversion script


nullset
09-26-2006, 07:43 PM
Ever since the latest update to SD! I've been having problems getting my subversion backup scripts to run. Both worked fine before the update, and now neither works. I've even tried a different set of shell scripts, but to no avail.

=== BEGIN SCRIPT ===

#!/usr/bin/perl -w
#
# Perform a weekly backup of a Subversion repository,
# logging the most-recently-backed-up revision so an
# incremental script can be run other days.
$svn_repos = "/path/to/svn";
$backups_dir = "/path/to/svn-backup";
$next_backup_file = "weekly-full-backup." . `date +%Y%m%d`;
$youngest = `/usr/local/bin/svnlook youngest $svn_repos`;
chomp $youngest;
print "Backing up to revision $youngest\n";
`/usr/local/bin/svnadmin dump $svn_repos > $backups_dir/$next_backup_file`;
print "Compressing dump file...\n";
print `gzip -9 $backups_dir/$next_backup_file`;
open(LOG, ">$backups_dir/last_backed_up");
print LOG $youngest;
close LOG;

=== END SCRIPT ===

The script works from the command line if I'm authenticated as root, but I can't seem to get it to work under SD!

I've got the script set to execute (permissions of -rws--x--x), I've tried setting the SUID to both me and to the root, and every time SD! will fail with an error "Error | * Dumped revision 0." Because the error message isn't very descriptive I can only guess at what it means, but I've spent far too many hours now trying to sort it out on my own.

Can anyone help, or at least point me in a new direction?

dnanian
09-27-2006, 12:36 AM
We haven't changed the way these scripts are executing -- we're simply calling it... I have no idea why it wouldn't work.

(You would be running authenticated; you're sure that the SVN configuration can be read in the dump line?)

nullset
09-27-2006, 01:03 PM
(You would be running authenticated; you're sure that the SVN configuration can be read in the dump line?)

I'm sure that the SVN configuration can be read in the dump line. If I sudo run the same script from within the terminal the SVN dump works just fine. If I don't sudo before running the script, the dump fails. Honestly what seems to me to be happening is that SD! isn't running as authenticated (like it should) ... the script seems to fail in the same place in SD! as it does when I'm not running as a super user.

dnanian
09-27-2006, 01:27 PM
It's running authenticated. Try touching a root-owned file to see.

nullset
09-27-2006, 01:57 PM
Hmmm, that works OK. I'm still completely stumped. When SD! is authenticated it works as the root user, right? What group is it part of? Wheel? Could I be running into a problem if my script is a part of the wrong group?

dnanian
09-27-2006, 02:30 PM
We're running with straight-up authentication -- basically, like sudo. You won't want to re-suid your script, but I don't think it'll necessarily hurt... I think you might be making assumptions about what home folder you'll get that might mess things up.

nullset
09-27-2006, 03:38 PM
We're running with straight-up authentication -- basically, like sudo. You won't want to re-suid your script, but I don't think it'll necessarily hurt

OK, I'll try changing everything back to being owned by me.

... I think you might be making assumptions about what home folder you'll get that might mess things up.

Could you elaborate? Both the SVN repository and backup directory are in the home folder, and both are explicitly stated in my real script (sorry, I modified the script I posted to remove my home folder).

dnanian
09-27-2006, 04:31 PM
What I'm concerned about is that any settings would be in your user's Home folder and not necessarily where the EUID would be. You might want to print out some debugging (echo ~ and the like).

nullset
09-27-2006, 06:09 PM
This is a bit over my head, but attaching an "echo ~" to my script shows the correct home folder for *me*. Should it be showing something different since SD! is running as root?

nullset
09-27-2006, 06:27 PM
Can you tell me where the log for SD! is located in the Mac file system? The default log message is a little sparse, and I'm hoping that the regular log will have more info about what's failing.

dnanian
09-28-2006, 10:00 AM
OK -- so, the process is running as you, but with root perms, just like 'sudo'. That's what I'd expect.

The log's location can be discovered by Cmd-clicking the title bar of a log window.

nullset
09-28-2006, 01:46 PM
Thanks for all your help figuring this problem out. I think I've finally got it fixed. After stripping my script down all the way down to a simple svn dump and still having it fail, I tried messing with some of the options of the dump itself. It turns out that SD! will fail when doing a svn dump unless you explicitly enable the -q flag (means "no progress (only errors) to stderr").

I imagine this tip might help others if they have shell scripts that are mysteriously failing.

dnanian
09-28-2006, 02:09 PM
This wouldn't have changed at all, though, since the last version: we always fail when the command outputs to stderr (since, of course, it indicates there's an error)...

nullset
09-28-2006, 03:57 PM
This wouldn't have changed at all, though, since the last version:

Hmmm, really weird then. The script worked fine for 4-5 months before it suddenly started failing. Guess I should count myself lucky that it worked as long as it did. Sorry to waste your time with this.

we always fail when the command outputs to stderr (since, of course, it indicates there's an error)...

In this case, however, svnadmin seems to be outputting the progress of the svn dump to stderr, even when there is no error at all.

dnanian
09-28-2006, 04:23 PM
Yeah, understood. Don't know why it does that (probably to make it easier for tools to separate the streams).

Anyway, no trouble, glad you figured it out!