Changeset 247


Ignore:
Timestamp:
Oct 13, 2008, 6:04:39 PM (16 years ago)
Author:
joergs
Message:

bugfix, better error handling for changing checkout user credentials

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r244 r247  
    3636my $DASSCM_REPOSITORY_NAME;
    3737my $DASSCM_SVN_REPOSITORY;
     38my $DASSCM_CHECKOUT_USERNAME;
     39my $DASSCM_CHECKOUT_PASSWORD;
     40
    3841
    3942# current directory at program start
     
    201204        if ( "$USER" eq "root" ) {
    202205            if ( ( not $DASSCM_USERNAME ) and ( $command ne "login" ) ) {
    203                 fatalerror( "Envirnonment variable DASSCM_USERNAME not set.", "Set DASSCM_USERNAME to your subversion user account or", "use 'dasscm login'";
     206                fatalerror( "Envirnonment variable DASSCM_USERNAME not set.", "Set DASSCM_USERNAME to your subversion user account or", "use 'dasscm login'" );
    204207            }
    205208            $svnOptions .= " --no-auth-cache ";
     
    356359}
    357360
    358 sub svn_check_credentials( $$ )
     361
     362
     363sub svn_check_credentials( $$;$$ )
    359364{
    360365    my $username = shift;
    361366    my $password = shift;
    362367
    363     print "checking credentials ... ";
     368    # check silently are allow user interaction?
     369    my $interactive = shift || 0;
     370
     371    # default: exit program, if repository is not accessable
     372    #   (do not exit for 'init')
     373    my $fatalerror = shift || 1;
     374
     375
     376
     377    print "checking credentials ";
    364378
    365379    if ( !$username ) {
     
    370384        fatalerror("no password given");
    371385    }
     386
     387    print "for " . $username . "@" . $DASSCM_SVN_REPOSITORY . ": ";
    372388
    373389    # Options for "svn info" are not supported by subversion 1.0.0 (SLES9),
     
    379395    #print @result;
    380396
    381     ( my $rc_update, my @result ) =
    382       run_command(
    383         "$SVN ls --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
    384       );
    385 
    386     if ( $rc_update != 0 ) {
    387         print "\n", @result;
    388         fatalerror();
    389     }
    390 
    391 }
     397    my $rc_update;
     398    if( $interactive ) {
     399        $rc_update = run_interactive( "$SVN ls --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY" );
     400    } else {
     401        ( $rc_update, my @result ) =
     402        run_command(
     403            "$SVN ls --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
     404        );
     405   
     406        if ( $rc_update != 0 ) {
     407            print "\n", @result;
     408            if( $fatalerror ) {
     409                fatalerror();
     410            }
     411            return;
     412        }
     413    }
     414
     415    # return success
     416    return $rc_update == 0;
     417}
     418
     419
    392420
    393421sub svn_update( ;$ )
     
    504532        $input_username = <STDIN>;
    505533        chomp($input_username);
     534
     535        $input_username = $input_username || $DASSCM_USERNAME;
    506536    }
    507537
    508538    # hidden password input
    509     print "Enter DASSCM user password: ";
     539    print "Enter password for $input_username: ";
    510540    ReadMode('noecho');
    511541    my $input_password = <STDIN>;
     
    514544    print "\n";
    515545
    516     svn_check_credentials( $input_username || $DASSCM_USERNAME,
    517         $input_password );
     546    # checking checkout username/password
     547    svn_check_credentials( $DASSCM_CHECKOUT_USERNAME, $DASSCM_CHECKOUT_PASSWORD );
     548    print "checkout access okay\n";
     549
     550    svn_check_credentials( $input_username, $input_password );
    518551
    519552    #
     
    856889      $config->{'DASSCM_SVN_REPOSITORY_BASE'} . "/" . $DASSCM_REPOSITORY_NAME;
    857890
    858     my $DASSCM_CHECKOUT_USERNAME = $config->{'DASSCM_CHECKOUT_USERNAME'};
    859     my $DASSCM_CHECKOUT_PASSWORD = $config->{'DASSCM_CHECKOUT_PASSWORD'};
     891    $DASSCM_CHECKOUT_USERNAME = $config->{'DASSCM_CHECKOUT_USERNAME'};
     892    $DASSCM_CHECKOUT_PASSWORD = $config->{'DASSCM_CHECKOUT_PASSWORD'};
    860893
    861894    #
Note: See TracChangeset for help on using the changeset viewer.