void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes)
{
	centscreen_mode_t	newmode, curmode;
	
	newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1;
	newmode.physx = width;
	newmode.physy = height;
	newmode.plan = planes;
	Vwrite(0, &newmode, &curmode);

	/* Disable screensaver */
	Vread(&newmode);
	newmode.mode &= ~(CSCREEN_SAVER|CSCREEN_ENERGYSTAR);
	Vwrite(0, &newmode, &curmode);
}
Esempio n. 2
0
static void *
xdlsym(void *handle, const char *symbol)
{
  void	*res = dlsym(handle, symbol);
  if (res==0) {
    char const	*error = dlerror();
    Vwrite(2, symbol, strlen(symbol));
    Vwrite(2, ": ", 2);
    Vwrite(2, error, strlen(error));
    Vwrite(2, "\n", 2);

    _exit(255);
  }

  return res;
}
Esempio n. 3
0
int main(int UNUSED argc, char *argv[])
{
  int		fd = open(argv[1], O_NOFOLLOW|O_NONBLOCK|O_RDONLY|O_NOCTTY);
  struct stat	st;
  off_t		size;
  struct {
      volatile unsigned int	canary0;
      volatile unsigned int	canary1;
      HashPath 			d;
      volatile unsigned int	canary2;
      volatile unsigned int	canary3;
  } __attribute__((__packed__))	d_path;
 
  d_path.canary0 = 0x12345678;
  d_path.canary1 = 0x21436587;
  d_path.canary2 = 0x89abcdef;
  d_path.canary3 = 0x98badcfe;
  memset(d_path.d, 0x66, sizeof d_path.d);

  ensc_crypto_init();
  global_info.hash_conf.method = ensc_crypto_hash_find(argv[2]);
  
  assert(ensc_crypto_hashctx_init(&global_info.hash_context,
				  global_info.hash_conf.method)!=-1);

  assert(fstat(fd, &st)!=-1);

    // set members of st to defined values so that the hash (which is
    // influenced by them) is predictable
  size = st.st_size;
  memset(&st, 0, sizeof st);
  st.st_size = size;
  
  assert(calculateHashFromFD(fd, d_path.d, &st));
  assert(d_path.canary0 == 0x12345678);
  assert(d_path.canary1 == 0x21436587);
  assert(d_path.canary2 == 0x89abcdef);
  assert(d_path.canary3 == 0x98badcfe);

  Vwrite(1, d_path.d, strlen(d_path.d));
  Vwrite(1, "\n", 1);
  
  ensc_crypto_hashctx_free(&global_info.hash_context);
  
  return 0;
}
Esempio n. 4
0
void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)
{
	centscreen_mode_t	newmode, curmode;

	/* Restore old video mode */
	newmode.handle = prev_handle;
	newmode.mode = newmode.physx = newmode.physy = newmode.plan =
		newmode.logx = newmode.logy = -1;
	Vwrite(0, &newmode, &curmode);
}
Esempio n. 5
0
static int
assumeNonNull(PathInfo const *cfgdir, char const *file, char const *val)
{
    if (val!=0) return 0;

    WRITE_MSG(2, "vserver-start: no value configured for '");
    Vwrite   (2, cfgdir->d, cfgdir->l);
    WRITE_MSG(2, "/");
    WRITE_STR(2, file);
    WRITE_STR(2, "'\n");
    return 1;
}
Esempio n. 6
0
static size_t
findUtsIdx(char const *str, size_t len)
{
  size_t		i;
  for (i=0; i<DIM_OF(UTS_STRINGS); ++i)
    if (UTS_STRINGS[i]!=0 && strncasecmp(UTS_STRINGS[i], str, len)==0)
      return i;

  WRITE_MSG(2, "Tag '");
  Vwrite   (2, str, len);
  WRITE_STR(2, "' not recognized\n");
  exit(wrapper_exit_code);
}
Esempio n. 7
0
static void
parseUMask(char const *str, struct vc_umask *umask)
{
  struct vc_err_listparser	err;
  int				rc;

  rc = vc_list2umask(str, 0, &err, umask);
  
  if (rc==-1) {
    WRITE_MSG(2, "Unknown namespace '");
    Vwrite(2, err.ptr, err.len);
    WRITE_MSG(2, "'\n");
    exit(wrapper_exit_code);
  }
}
Esempio n. 8
0
static void
parseCCaps(char const *str, struct vc_ctx_caps *caps)
{
  struct vc_err_listparser	err;
  int				rc;

  rc = vc_list2ccap(str,0, &err, caps);
  
  if (rc==-1) {
    WRITE_MSG(2, "Unknown ccap '");
    Vwrite(2, err.ptr, err.len);
    WRITE_MSG(2, "'\n");
    exit(wrapper_exit_code);
  }
}
Esempio n. 9
0
static void
parseFlags(char const *str, struct vc_ctx_flags *flags)
{
  struct vc_err_listparser	err;
  int				rc;

  rc = vc_list2cflag(str,0, &err, flags);
  
  if (rc==-1) {
    WRITE_MSG(2, "Unknown flag '");
    Vwrite(2, err.ptr, err.len);
    WRITE_MSG(2, "'\n");
    exit(wrapper_exit_code);
  }
}
Esempio n. 10
0
int main (int argc, char *argv[])
{
  int			idx = 1;
  struct stat		st;
  
  if (argc>=2) {
    if (strcmp(argv[1], "--help")   ==0) showHelp(argv[0]);
    if (strcmp(argv[1], "--version")==0) showVersion();
    if (strcmp(argv[1], "--")       ==0) ++idx;
  }
  if (argc<idx+1)
    WRITE_MSG(2, "No filename specified; use '--help' for more information\n");
  else if (stat(argv[idx], &st)==-1)
    PERROR_Q("stat", argv[idx]);
  else {    
    time_t	now     = time(NULL);
    time_t	since   = now - st.st_mtime;
    int		days    = since / (24*60*60);
    int		today   = since % (24*60*60);
    int		hours   = today / (60*60);
    int		minutes = (today % (60*60)) / 60;

    char	buf[3*sizeof(time_t)*3 + 128];
    size_t	l = 0;

    if (days > 0) {
      l        = utilvserver_fmt_ulong(buf, days);
      buf[l++] = ' ';
      #define MSG	"days, "
      memcpy(buf+l, MSG, sizeof(MSG)-1); l += sizeof(MSG)-1;
    }

    if (hours<10) buf[l++] = '0';
    l += utilvserver_fmt_ulong(buf+l, hours);
    buf[l++] = ':';
    if (minutes<10) buf[l++] = '0';
    l += utilvserver_fmt_ulong(buf+l, minutes);
    buf[l++] = '\n';

    Vwrite(1, buf, l);
    return EXIT_SUCCESS;
  }

  return EXIT_FAILURE;
}
Esempio n. 11
0
static void
printReducecap(struct __user_cap_data_struct *user)
{
  int i;
  WRITE_MSG(1, "            Capability Effective  Permitted  Inheritable\n");

  for (i=0;; ++i) {
    size_t const	len  = 23 + 10*2 + 4+2;
    char const *	text = vc_cap2text(i);
    int			bit  = 1<<i;
    size_t		l;
    char		buf[len];
    if (text==0) break;

    memset(buf, ' ', sizeof buf);
    buf[len-1] = '\n';
    l = MIN(strlen(text), 22);
    memcpy(buf, text, l);
    buf[23 + 10*0 + 4] = (user->effective   & bit) ? 'X' : ' ';
    buf[23 + 10*1 + 4] = (user->permitted   & bit) ? 'X' : ' ';
    buf[23 + 10*2 + 4] = (user->inheritable & bit) ? 'X' : ' ';
    Vwrite(1, buf, len);
  }
}
Esempio n. 12
0
int main (int argc, char *argv[])
{
  uint32_t		remove  = 0;
  bool			do_show = false;
  uint32_t		flags   = 0;
  pid_t			pid     = 0;
#ifdef VC_ENABLE_API_LEGACY
  bool			show_obsolete_warning = true;
#endif    

  while (1) {
    int		c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
    if (c==-1) break;

#ifdef VC_ENABLE_API_LEGACY
    if (c>=CMD_OBSOLETE_CHOWN && c<=CMD_OBSOLETE_X_QUOTACTL) {
      if (show_obsolete_warning) {
	WRITE_MSG(2, "reducecap: warning, obsolete CLI used\n");
	show_obsolete_warning = false;
      }

      remove = getCap(OBSOLETE_MAPPING[c-CMD_OBSOLETE_CHOWN]);
      continue;
    }
#endif    
    switch (c) {
      case CMD_HELP		:  showHelp(1, argv[0], 0);
      case CMD_VERSION		:  showVersion();
      case CMD_SHOW		:  do_show = true;  break; 
      case CMD_PID		:  pid     = atoi(optarg);   break;
#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
      case CMD_SECURE		:  remove  = vc_get_insecurebcaps(); break;
      case CMD_CAP		:  remove  = getCap(optarg); break;
      case CMD_FLAG		: {
	struct vc_err_listparser	err;
	
	flags = vc_list2cflag_compat(optarg, 0, &err);
	if (err.ptr!=0) {
	  WRITE_MSG(2, "Unknown flag '");
	  Vwrite(2, err.ptr, err.len);
	  WRITE_MSG(2, "'\n");
	  exit(wrapper_exit_code);
	}
	break;
      }
#else
      case CMD_SECURE		:  
      case CMD_CAP		:
      case CMD_FLAG		:  flags = 0; remove = 0; break;
#endif
    }
  }

  if (!do_show && optind==argc) {
    WRITE_MSG(2, "No command given; use '--help' for more information\n");
    exit(wrapper_exit_code);
  }

  if (!do_show && pid!=0) {
    WRITE_MSG(2, "A pid can be specified in '--show' mode only; use '--help' for more information\n");
    exit(wrapper_exit_code);
  }  

  if (do_show && optind==argc)
    show(pid);
#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
  else {
    Evc_new_s_context(VC_SAMECTX, remove, flags);
    if (do_show) show(pid);

    WRITE_MSG(2, "Executing\n");
    Eexecvp(argv[optind], argv+optind);
  }
#else
  else if (do_show)
Esempio n. 13
0
bool
Iface_read(struct Interface *res, PathInfo *cfgdir,
           struct Interface const *dflt)
{
    char const *	extip;
    char const *	ip;
    char const *	mask;
    char const *	prefix;
    char const *	bcast;
    bool		rc = false;

    // skip 'disabled' interfaces
    if (readEntryFlag(cfgdir, "disabled", false)) return true;

    ip          =  readEntryStr (cfgdir, "ip",       0);
    mask        =  readEntryStr (cfgdir, "mask",     0);
    prefix      =  readEntryStr (cfgdir, "prefix",   0);
    extip       =  readEntryStr (cfgdir, "extip",    0);
    bcast       =  readEntryStr (cfgdir, "bcast",    0);
    res->mac    =  readEntryStr (cfgdir, "mac",      0);
    res->name   =  readEntryStr (cfgdir, "name",     0);
    res->dev    =  readEntryStr (cfgdir, "dev",      dflt ? dflt->dev   : 0);
    res->scope  =  readEntryStr (cfgdir, "scope",    dflt ? dflt->scope : 0);
    res->nodev  =  readEntryFlag(cfgdir, "nodev",    false);
    res->direct = !readEntryFlag(cfgdir, "indirect", false);
    res->up     = !readEntryFlag(cfgdir, "down",     false);

    if (dflt && (
                assumeNonNull(cfgdir, "ip",  ip) +
                assumeNonNull(cfgdir, "dev", res->dev) +
                (dflt->addr.ipv4.mask>0) ? 0 : (
                    (mask   ? 0 : assumeNonNull(cfgdir, "prefix", prefix)) +
                    (prefix ? 0 : assumeNonNull(cfgdir, "mask",   mask))
                )))
        goto err;

    if (mask && prefix) {
        WRITE_MSG(2, "vserver-start: both 'prefix' and 'mask' specified in '");
        Vwrite   (2, cfgdir->d, cfgdir->l);
        WRITE_MSG(2, "'\n");
        goto err;
    }

    if (bcast)
        res->addr.ipv4.bcast = inet_addr(bcast);

    if (ip)
        res->addr.ipv4.ip    = inet_addr(ip);

    if (extip)
        res->addr.ipv4.extip = inet_addr(extip);

    if (prefix) {
        int		p = atoi(prefix);
        if (p==0) {
            WRITE_MSG(2, "vserver-start: invalid 'prefix' specified in '");
            Vwrite   (2, cfgdir->d, cfgdir->l);
            WRITE_MSG(2, "'\n");
            goto err;
        }

        res->addr.ipv4.mask = htonl(-1u << (32-p));
    }
    else if (mask)
        res->addr.ipv4.mask = inet_addr(mask);
    else if (dflt)
        res->addr.ipv4.mask = dflt->addr.ipv4.mask;

    rc = true;

err:
    free(const_cast(void *)(bcast));
    free(const_cast(void *)(extip));
    free(const_cast(void *)(ip));
    free(const_cast(void *)(mask));
    free(const_cast(void *)(prefix));

    return rc;
}