[Mplayer-cvslog] CVS: main fibmap_mplayer.c,1.3,1.4 Makefile,1.278,1.279
Attila Kinali CVS
attila at mplayerhq.hu
Mon Dec 8 12:22:33 CET 2003
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv24782
Modified Files:
fibmap_mplayer.c Makefile
Log Message:
Security fixes for fibmap_mplayer by Adam Rice <adamrice at ntlworld.com>
Index: fibmap_mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/fibmap_mplayer.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- fibmap_mplayer.c 4 Jan 2002 13:08:13 -0000 1.3
+++ fibmap_mplayer.c 8 Dec 2003 11:21:59 -0000 1.4
@@ -11,28 +11,51 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include "mp_msg.h"
+
#ifndef FIBMAP
#define FIBMAP 1
#endif
int main ( int argc , char ** argv )
{
- int fd,lba=0;
- if (argc!=2) {
- fprintf(stderr,"Bad usage.\n");
+ int fd,ret,lba=0;
+ if (geteuid()!=0) {
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL, "%s must be setuid root to work\n",
+ argv[0]);
+ return 1;
+ }
+ if (seteuid(getuid()) == -1) {
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL, "Couldn't drop privileges: %s\n",
+ strerror(errno));
+ return 1;
+ }
+ if (argc!=2 || argv[1]==NULL) {
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Usage: %s <filename>\n", argv[0]);
return 1;
}
if ((fd = open(argv[1], O_RDONLY)) == -1) {
- fprintf(stderr,"Cannot open file %s: %s\n",
- argv[1] ? argv[1] : "(NULL)", strerror(errno));
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Cannot open file %s: %s\n",
+ argv[1], strerror(errno));
return 1;
}
- if (ioctl(fd, FIBMAP, &lba) != 0) {
- fprintf(stderr,"fibmap ioctl: %s (Hint: %s is not suid root?)\n",strerror(errno),argv[0]);
- close(fd);
+ if (seteuid(0) == -1) {
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL, "Couldn't restore root privileges: %s\n",
+ strerror(errno));
+ return 1;
+ }
+ ret = ioctl(fd, FIBMAP, &lba);
+ if (seteuid(getuid()) == -1) {
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL, "Couldn't re-drop privileges: %s\n",
+ strerror(errno));
+ return 1;
+ }
+ close(fd);
+ if (ret != 0) {
+ mp_msg(MSGT_CPLAYER,MSGL_FATAL,"fibmap ioctl failed: %s\n",
+ strerror(errno));
return 1;
}
- close(fd);
printf("%d\n",lba);
return 0;
}
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.278
retrieving revision 1.279
diff -u -r1.278 -r1.279
--- Makefile 18 Nov 2003 02:32:42 -0000 1.278
+++ Makefile 8 Dec 2003 11:21:59 -0000 1.279
@@ -230,8 +230,8 @@
./darwinfixlib.sh $(MPLAYER_DEP)
$(CC) $(CFLAGS) -shared -Wl,-Bsymbolic -o mplayer_wine.so mplayer_wine.spec.c $(OBJS_MPLAYER) libvo/libvo.a libao2/libao2.a $(MENU_LIBS) $(VIDIX_LIBS) $(GUI_LIBS) $(COMMON_LIBS) $(GTK_LIBS) $(VO_LIBS) $(AO_LIBS) $(EXTRA_LIB) $(LIRC_LIB) $(LIRCC_LIB) $(STATIC_LIB) -lwine $(ARCH_LIB) -lm
-$(PRG_FIBMAP): fibmap_mplayer.o
- $(CC) -o $(PRG_FIBMAP) fibmap_mplayer.o
+$(PRG_FIBMAP): fibmap_mplayer.o mp_msg.o
+ $(CC) -o $(PRG_FIBMAP) fibmap_mplayer.o mp_msg.o
ifeq ($(MENCODER),yes)
$(PRG_MENCODER): $(MENCODER_DEP)
More information about the MPlayer-cvslog
mailing list