Almost as is, I've merged in a patch that allows read or write access
depending on the permissions that the user running it has. So
non-superuser read access is still allowed.

BTW: You missed a sizeof(utmp_entry) or two in the lseek's args

-- 
Rob.                          (Robert de Bath <http://poboxes.com/rdebath>)
                    <rdebath @ poboxes.com> <http://www.cix.co.uk/~mayday>

On Fri, 29 Jan 1999, Alistair Riddoch wrote:

> Hi,
> 
> The patch included below fixes the two obvious bugs I spotted in the utent
> functions in dev86 while I was implementing utmp stuff this afternoon.
> The next release of ELKS will require this to be fixed to build correctly.
> 
> Rob, could you megre this lot into your sources, and include it in your
> next release.
> 
> Al
> 
> -------------------------------------------------------
> --- utent.c.old Tue Mar 19 20:16:38 1996
> +++ utent.c     Sat Jan 30 00:15:42 1999
> @@ -32,7 +32,7 @@
>  {
>    if (ut_fd!=-1)
>      close(ut_fd);
> -  if ((ut_fd=open(ut_name, O_RDONLY))<0)
> +  if ((ut_fd=open(ut_name, O_RDWR))<0)
>      {
>        perror("setutent: Can't open utmp file");
>        ut_fd=-1;
> @@ -124,15 +124,15 @@
>    if ((ut=getutid(utmp_entry))!=NULL)
>      {
>        lseek(ut_fd, (off_t) -sizeof(utmp_entry), SEEK_CUR);
> -      if (write(ut_fd, (char *) utmp_entry, sizeof(utmp_entry))
> -         != sizeof(utmp_entry))
> +      if (write(ut_fd, (char *) utmp_entry, sizeof(struct utmp))
> +         != sizeof(struct utmp))
>         return NULL;
>      }
>    else
>      {
>        lseek(ut_fd, (off_t) 0, SEEK_END);
> -      if (write(ut_fd, (char *) utmp_entry, sizeof(utmp_entry))
> -         != sizeof(utmp_entry))
> +      if (write(ut_fd, (char *) utmp_entry, sizeof(struct utmp))
> +         != sizeof(struct utmp))
>         return NULL;
>      }
>  
> ---------------------------------------------------------
> 

Reply via email to