Index: trunk/dasscm/dasscm
===================================================================
--- trunk/dasscm/dasscm	(revision 277)
+++ trunk/dasscm/dasscm	(revision 278)
@@ -358,12 +358,12 @@
             my $mode = get_type( $info->mode ) & 07777;
             my $modestring = sprintf( "%04o", $mode );
-            my $uid        = $info->uid;
-            my $uidname    = getpwuid($uid);
-            my $gid        = $info->gid;
-            my $gidname    = getgrgid($gid);
+            my $uidnumber  = $info->uid;
+            my $uid        = getpwuid($uidnumber) || $uidnumber;
+            my $gidnumber  = $info->gid;
+            my $gid        = getgrgid($gidnumber) || $gidnumber;
             push(
                 @permlist,
                 sprintf( "%-55s %-17s %4d",
-                    $file, "${uidname}:${gidname}", $modestring )
+                    $file, "${uid}:${gid}", $modestring )
             );
         } else {
@@ -597,4 +597,5 @@
     my %removedfiles = ();
     my %changedfiles = ();
+    my %unknownfiles = ();
 
     # create list of modified files
@@ -607,10 +608,18 @@
 
             if ( -d $realfile ) {
-                ## directory. do nothing
+                # directory
+                if( !-d "$cvsworkfile" ) {
+                    # real is directory, repository is not. This is a problem
+                    $changedfiles{"$realfile"} = $cvsworkfile;
+                }
+            } elsif ( !-e $realfile ) {
+                $removedfiles{"$realfile"} = $cvsworkfile;
             } elsif ( !-r $realfile ) {
-                $removedfiles{"$realfile"} = $cvsworkfile;
+                # don't have permission to read the file,
+                # can't check it
+                $unknownfiles{"$realfile"} = $cvsworkfile;
             } else {
                 ( -r "$cvsworkfile" )
-                  || die("Fehler: $cvsworkfile ist nicht lesbar");
+                  || fatalerror("failed to read $cvsworkfile");
                 if ( compare( $cvsworkfile, $realfile ) != 0 ) {
                     $changedfiles{"$realfile"} = $cvsworkfile;
@@ -620,5 +629,5 @@
     }
 
-    return ( \%changedfiles, \%removedfiles );
+    return ( \%changedfiles, \%removedfiles, \%unknownfiles );
 }
 
@@ -732,6 +741,9 @@
       "DASSCM_PASSWORD:   (hidden)\n", "DASSCM_PROD:       $DASSCM_PROD\n",
       "DASSCM_REPO:       $DASSCM_REPO\n",
-      "Server Repository: $DASSCM_SVN_REPOSITORY\n", "\n", "[dasscm shell]\n\n";
-
+      "Server Repository: $DASSCM_SVN_REPOSITORY\n", "\n";
+
+    status();
+
+    print "\n[dasscm shell]\n\n";
     my $shell = $SHELL || "bash";
     exec($shell) or die "failed to start new shell";
@@ -1019,26 +1031,33 @@
     # update local repository
     #
-    svn_update( $filename_prod );
-
-    ( my $refChangedFiles, my $refRemovedFiles ) =
+    #svn_update( $filename_prod );
+
+    # check, if permissions have changed
+    permissions();
+
+    # get modified files
+    ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) =
       getModifiedFiles($dirname_prod);
     my %changedfiles = %{$refChangedFiles};
     my %removedfiles = %{$refRemovedFiles};
-
-    if ( %removedfiles or %changedfiles ) {
+    my %unknownfiles = %{$refUnknownFiles};
+
+    if ( %removedfiles or %changedfiles or %unknownfiles ) {
+
         if (%removedfiles) {
-            print "deleted files (found in repository, but not in system):\n";
-            foreach my $key ( keys %removedfiles ) {
-                print "$key\n";
-            }
-            print "\n";
+            print "DELETED: files found in repository, but not in system:\n";
+            print join( "\n", ( keys %removedfiles ) ) . "\n\n";
         }
 
         if (%changedfiles) {
-            print "modified files:\n";
-            foreach my $key ( keys %changedfiles ) {
-                print "$key\n";
-            }
-        }
+            print "MODIFIED: files differs between repository and system:\n";
+            print join( "\n", ( keys %changedfiles ) ) . "\n\n";
+        }
+
+        if (%unknownfiles) {
+            print "UNKNOWN: insufficient permission to check files:\n";
+            print join( "\n", ( keys %unknownfiles ) ) . "\n\n";
+        }
+
     } else {
         print "no modified files found in $dirname_repo\n";
@@ -1057,12 +1076,16 @@
 
     # return code for the shell
-    # default: error
     my $return_code = $RETURN_OK;
     my $return_string = "OK: no modified files";
 
-    ( my $refChangedFiles, my $refRemovedFiles ) =
+    # check, if permissions have changed
+    permissions();
+
+    # get modified files
+    ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) =
       getModifiedFiles( "/" );
     my %changedfiles = %{$refChangedFiles};
     my %removedfiles = %{$refRemovedFiles};
+    my %unknownfiles = %{$refUnknownFiles};
 
     if ( %removedfiles or %changedfiles ) {
@@ -1074,4 +1097,7 @@
             $return_string .= "removed: " . join( ", ", ( keys %removedfiles ) ) . ". ";
         }
+        if (%unknownfiles) {
+            $return_string .= "unknown: " . join( ", ", ( keys %unknownfiles ) ) . ". ";
+        }
         $return_code = $RETURN_WARN;
     }
@@ -1089,4 +1115,6 @@
 {
     check_env();
+
+    my $return_code = $RETURN_OK;
 
     #
@@ -1108,5 +1136,4 @@
 
             # Verzeichnis existiert => schreiben
-            print "storing permissions in file $permissions_file\n";
             open( OUTFILE, ">$permissions_file" )
               || die("failed to write to $permissions_file: $!");
@@ -1118,8 +1145,16 @@
         } else {
 
-            # Pfad für Sicherungsdatei existiert nicht => schreiben auf stdout
-            # Alias Filehandle für stdout erzeugen
-            *OUTFILE = *STDOUT;
-        }
+            if( $command eq "permission" ) {
+                # Pfad für Sicherungsdatei existiert nicht => schreiben auf stdout
+                # Alias Filehandle für stdout erzeugen
+                $return_code = $RETURN_WARN;
+                *OUTFILE = *STDOUT;
+            } else {
+                # TODO: improve this. Check for diff?
+                $return_code = $RETURN_CRIT;
+                return $return_code;
+            }
+        }
+
         foreach my $line (@permissions) {
             print OUTFILE "$line\n";
@@ -1130,4 +1165,6 @@
         }
     }
+
+    return $return_code;
 }
 
@@ -1230,5 +1267,5 @@
     } elsif (m/^permissions$/i) {
         $command = "permissions";
-        permissions();
+        $return_code = permissions();
     } elsif (m/^cleanup$/i) {
         $command = "cleanup";
