示例#1
0
void FilePropsDialog::initOwner() {
  if(allNative) {
    if(uid != DIFFERENT_UIDS)
      ui->owner->setText(uidToName(uid));
    if(gid != DIFFERENT_GIDS)
      ui->ownerGroup->setText(gidToName(gid));

    if(geteuid() != 0) { // on local filesystems, only root can do chown.
      ui->owner->setEnabled(false);
      ui->ownerGroup->setEnabled(false);
    }
  }
}
示例#2
0
void ListFile::show_file_info(FILE * fp, char *file, struct stat * info)
{
		char modeStr[11];
		mode_to_letters(info->st_mode, modeStr);
		fprintf(fp, "%s ", modeStr);
		fprintf(fp, "%4d ", (int)(info->st_nlink));
		fprintf(fp, "%-8s ", uidToName(info->st_uid));
		fprintf(fp, "%-8s ", gidToName(info->st_gid));
		fprintf(fp, "%8ld", (long)(info->st_size));
		fprintf(fp, "%.12s ", 4 + ctime(&info->st_mtime));
		fprintf(fp, "%s\n", file);

}
示例#3
0
文件: print.c 项目: bol/boc
int listProc(struct Process * proc) {
		printf("%-7d %c ", proc->pid, proc->state);
		if (TESTOPT(OPT_USER)) {
			printf("%-10s %-10s ", uidToName(proc->euid), gidToName(proc->egid));
		}
		if (TESTOPT(OPT_IO)) {
			printf("%-10d %-10d", proc->read_bytes/1024, (proc->write_bytes - proc->cancelled_write_bytes)/1024);
		}
		if (TESTOPT(OPT_MEM)) {
			printf("%-10d %-10d %-10d %-10d %-10d ", proc->size, proc->resident, proc->share, proc->text, proc->data);
		}
		printf("%-25s\n", (proc->has_commandline? fullArgv(proc):proc->name));

		return 0;
}
示例#4
0
credentials_t::credentials_t(const QDBusMessage &message)
: uid("nobody"), gid("nobody")
{
  QString sender = message.service() ;
  uint32_t user_id = get_name_owner_from_dbus_sync(Maemo::Timed::bus(), sender) ;

  if (user_id == ~0u)
    log_warning("can't get user (uid) of the caller, already terminated?") ;
  else
  {
    passwd *info = getpwuid(user_id) ;
    if (info)
    {
      uid = info->pw_name ;
      gid = gidToName(info->pw_gid) ;
    }
  }
}
示例#5
0
credentials_t credentials_t::from_current_process()
{
  return credentials_t(uidToName(getuid()), gidToName(getgid())) ;
}