- out_fd = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, uid, gid);
+ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+
+ if (uid < 0 || gid < 0) {
+ out_fd = open(path, flags, mode);
+ } else {
+ out_fd = run_as_open(path, flags, mode, uid, gid);
+ }