Growing the init_rtems_rootfs was How to Enable DNS (Using PPPD)

Fernando RUIZ CASAS correo at fernando-ruiz.com
Fri Nov 2 20:22:21 UTC 2001


Hi Cris and All.

 Looking the source I can find the above code with the same goal.

++++++++++++++++ rtems-ss-20011017\c\src\lib\libc\getpwent.c
++++++++++++++++++++++

static char etc_passwd_initted = 0;

void init_etc_passwd_group(void)
{
  FILE *fp;

  if ( etc_passwd_initted )
    return;
  etc_passwd_initted = 1;

  (void) mkdir( "/etc", 0777);

  /*
   *  Initialize /etc/passwd
   */

  if ((fp = fopen ("/etc/passwd", "w")) == NULL)
    return;

  fprintf( fp, "root:*:0:0:root,,,,:/:/bin/sh\n"
               "rtems:*:1:1:RTEMS Application,,,,:/:/bin/sh\n"
               "tty:!:2:2:tty owner,,,,:/:/bin/false\n" );

  fclose( fp );

  /*
   *  Initialize /etc/group
   */

  if ((fp = fopen ("/etc/group", "w")) == NULL)
    return;

  fprintf( fp, "root:x:0:root\n"
               "rtems:x:1:rtems\n"
               "tty:x:2:tty\n" );

  fclose( fp );
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+

This code has been modified by me in order to add two users and groups.
This code is called always when you call getpwent() the first time.
I suppose that this is a trick done by OAR to give a real behaviour at the
function.

How I need two users ('rtems' a non priviliged user and the dummy 'tty'
owner)
I have added these two lines at the original files.

In the same way two files are very friendly when the user makes a login in
the system.
The /etc/issue & /etc/issue.net

+++++++++++++++++++++rtems-ss-20011017\c\src\libmisc\shell\shell.c++++++++++
+++

void write_file(char * name,char * content) {
	FILE * fd;
	fd=fopen(name,"w");
	if (fd) {
  	 fwrite(content,1,strlen(content),fd);
	 fclose(fd);
	};
}

void init_issue(void) {
 static char issue_inited=FALSE;
 struct stat buf;
 if (issue_inited) return;
 issue_inited=TRUE;
 getpwnam("root"); /* dummy call to init /etc dir */
 if (stat("/etc/issue",&buf))
  write_file("/etc/issue",
 	     "Welcome to @V\\n"
	     "Login into @S(@L)\\n");
 if (stat("/etc/issue.net",&buf))
  write_file("/etc/issue.net",
 	     "Welcome to %v\n"
	     "running on %m\n");
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
In these files the macro expansion are done like Linux.
The /etc/motd is also showed when the file exists after the user login.

Cris.
Is't possible to grown the rtems_init_rootfs in the libmisc/rootfs with this
lines & new files?
Of course removing this duplicate code.

In the same way a /etc/passwd~ shadow password file with the crypt()
function in order to
give certain user login restriction in the ftpd() telnetd() and shell() user
login.

('ssh' is a real goal but too big for the moment)

Several times any users have said to improve the security in the rtems
application
and I think that this is a real need today in all system with tcp/ip with
user
interaction.

BRGDS.

Fernando RUIZ CASAS
home: correo at fernando-ruiz.com
work: fernando.ruiz at ctv.es


> -----Mensaje original-----
> De: cjohns at kiwi.objectivedesign.com.au
> [mailto:cjohns at kiwi.objectivedesign.com.au]En nombre de Chris Johns
> Enviado el: viernes, 02 de noviembre de 2001 13:58
> Para: fernando.ruiz at ctv.es
> CC: rtems-users at oarcorp.com
> Asunto: Re: How to Enable DNS (Using PPPD)
>
>
> "Fernando RUIZ CASAS (E-mail)" wrote:
> >
> > It's possible normalize the creation of a common rootfs tree with
> > ALL the files necesaries for each modules but in a shared place?
> >
>
> I have added c/src/libmisc/rootfs for this purpose.
>
> >
> > I can think about the tcp/ip stack files to be builded in a common
> > procedure.
> >
>
> The support is in the rootfs support. I have also added a new bootp
> command that creates the rootfs and various files with the results of
> the bootp request.
>
> --
>  Chris Johns, cjohns at cybertec.com.au
>




More information about the users mailing list