use sethostname(2)/setdomainname(2) again...
[util-vserver.git] / util-vserver / src / chxid.c
index 42bdd17..6af4790 100644 (file)
@@ -66,41 +66,20 @@ showVersion()
   exit(0);
 }
 
-static bool
-setFile(char const *name, char const * display_name, struct stat const *exp_st)
-{
-  bool         res = false;
-  int          fd = open(name, O_RDONLY);
-
-  if (fd==-1) {
-    perror("open()");
-    return false;
-  }
-
-  if (!exp_st ||
-      !checkForRace(fd, name, exp_st))
-    goto err;
-
-  if (vc_X_set_filecontext(fd, global_args->ctx)==-1) {
-    //perror("vc_X_set_filecontext()");
-    perror(display_name);
-    goto err;
-  }
-
-  res = true;
-
-  err:
-  close(fd);
-  return res;
-}
-
 bool
 handleFile(char const *name, char const * display_name,
           struct stat const *exp_st)
 {
-  if (S_ISLNK(exp_st->st_mode)) return true;
+  int  rc = vc_set_iattr_compat(name, exp_st->st_dev, exp_st->st_ino,
+                                global_args->ctx, 0, VC_IATTR_XID,
+                                &exp_st->st_mode);
   
-  return setFile(name, display_name, exp_st);
+  if (rc==-1) {
+    perror(display_name);
+    return false;
+  }
+
+  return true;
 }
 
 void
@@ -116,5 +95,6 @@ fixupParams(struct Arguments UNUSED *args, int argc)
     exit(1);
   }
 
-  args->ctx = resolveCtx(args->ctx_str);
+  args->ctx            = resolveCtx(args->ctx_str);
+  args->do_display_dir = false;  
 }