This file is indexed.

/usr/bin/realcsh.c is in binfmtc 0.17-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*BINFMTC: -lreadline -I/usr/include/readline
exit 1

 *  binfmt_misc C Interpreter
 *  Copyright (C) 2005-2006 Junichi Uekawa
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * test program: Real C shell implemented in binfmtc.
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <readline.h>
#include <history.h>

typedef struct defs_list
{
  struct defs_list* next;
  char* s;
} * defsp;


defsp add_string(defsp orig, const char* newstr)
{
  defsp t = malloc(sizeof(struct defs_list));
  t->next=orig;
  t->s=strdup(newstr);
  return t;
}

int main(int argc, char** argv)
{
  char * str = NULL;
  char * tempfilename = NULL;
  FILE * f;
  int fd;
  defsp t, defs=NULL;
  defsp header=NULL;
  int i;
  
  
  for (i=1; i < argc; ++i)
    header=add_string(header, argv[i]);
  
  defs=add_string(defs, "#include <stdlib.h>");
  defs=add_string(defs, "#include <unistd.h>");
  defs=add_string(defs, "#include <stdio.h>");

  while (NULL!=(str = readline("REAL csh: ")))
    {
      if (*str=='\0')		/* ignore blanks. */
	{
	  free(str);
	  continue;
	}
      
      add_history(str);

      if (*str=='#')
	{
	  /* ## debug symbol to dump header file list. */
	  if (*(str+1)=='#')
	    {
	      printf("defs:\n");
	      for (t=defs; t; t=t->next)
		{
		  printf("  %s\n", t->s);
		}
	      printf("header:\n");
	      for (t=header; t; t=t->next)
		{
		  printf("  %s\n", t->s);
		}
	      free(str);
	      continue;
	    }
	  defs=add_string(defs, str);
	  free(str);
	  continue;
	}
      asprintf(&tempfilename, "%s/realcshXXXXXX",
	       getenv("BINFMTCTMPDIR")?:
	       getenv("TMPDIR")?:
	       getenv("TEMPDIR")?:
	       "/tmp"
	       );
      f = fdopen(fd=mkstemp(tempfilename), "w");
      fchmod(fd, 0700);
      
      fprintf(f, 
	      "/*BINFMTC:");
      for (t=header; t; t=t->next)
	{
	  fprintf(f," %s", t->s);
	}
      
      fprintf(f, 
	      "\n*/\n");
      for (t=defs; t; t=t->next)
	{
	  fprintf(f, "%s\n", t->s);
	}
      fprintf(f, 
	      "int main(int argc, char ** argv)\n"
	      "{\n"
	      "%s;\n"
	      "return 0; \n"
	      "}\n",
	      str);
      fclose (f);
      system (tempfilename);
      unlink (tempfilename);
      free (str);
    }
  printf ("\n");
  return 0;
}