[Mplayer-cvslog] CVS: main Makefile,1.45,1.46 dvdauth.c,1.5,1.6

Gabor Lenart lgb at users.sourceforge.net
Tue Jun 19 01:56:21 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv27993/main

Modified Files:
	Makefile dvdauth.c 
Log Message:
According an idea, mplayer now can use external setuid root wrapper to do FIBMAP ioctl (requires root priv). Also, a serious bug was fixed in dvdauth.c made by some guy when mixing old and new style CSS API into dvdauth.c ;-)

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -r1.45 -r1.46
*** Makefile	2001/06/08 23:36:13	1.45
--- Makefile	2001/06/18 23:56:19	1.46
***************
*** 10,13 ****
--- 10,14 ----
  PRG_HQ = mplayerHQ
  PRG_AVIP = aviparse
+ PRG_FIBMAP = fibmap_mplayer
  PRG_TV = tvision
  PRG_CFG = codec-cfg
***************
*** 26,30 ****
  # .PHONY: all clean
  
! all:	$(PRG)
  # $(PRG_AVIP)
  
--- 27,31 ----
  # .PHONY: all clean
  
! all:	$(PRG) $(PRG_FIBMAP)
  # $(PRG_AVIP)
  
***************
*** 67,70 ****
--- 68,74 ----
  	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader $(DS_LIB) -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore -Llibao2 -lao2 $(VO_LIBS) $(CSS_LIB) -Lencore -lencore $(ARCH_LIBS)
  
+ $(PRG_FIBMAP): fibmap_mplayer.o
+ 	$(CC) -o $(PRG_FIBMAP) fibmap_mplayer.o
+ 
  # $(PRG_HQ):	depfile mplayerHQ.o $(OBJS) loader/libloader.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
  # 	$(CC) $(CFLAGS) -o $(PRG_HQ) mplayerHQ.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader -ldl -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore $(VO_LIBS) -Lencore -lencore -lpthread
***************
*** 79,85 ****
  	$(CC) $(CFLAGS) -g codec-cfg.c -o $(PRG_CFG) -DCODECS2HTML
  
! install: $(PRG)
  	install -D -m 755 -s $(PRG) $(BINDIR)/$(PRG)
  	install -D -m 644 DOCS/mplayer.1 $(prefix)/man/man1/mplayer.1
  
  clean:
--- 83,94 ----
  	$(CC) $(CFLAGS) -g codec-cfg.c -o $(PRG_CFG) -DCODECS2HTML
  
! install: $(PRG) $(PRG_FIBMAP)
  	install -D -m 755 -s $(PRG) $(BINDIR)/$(PRG)
  	install -D -m 644 DOCS/mplayer.1 $(prefix)/man/man1/mplayer.1
+ 	@echo "Following task requires root privs. If it fails don't panic"
+ 	@echo "however it means you can't use fibmap_mplayer."
+ 	@echo "Without this (or without running mplayer as root) you won't be"
+ 	@echo "able to play DVDs."
+ 	install -D -o root -g root -m 4755 -s $(PRG_FIBMAP) $(BINDIR)/$(PRG_FIBMAP)
  
  clean:
***************
*** 88,92 ****
  distclean:
  	@for a in mp3lib libac3 libmpeg2 opendivx encore libvo libao2 loader loader/DirectShow drivers drivers/syncfb ; do $(MAKE) -C $$a distclean ; done
! 	rm -f *~ $(PRG) $(PRG_HQ) $(PRG_AVIP) $(PRG_TV) $(OBJS) *.o *.a .depend
  
  dep:	depend
--- 97,101 ----
  distclean:
  	@for a in mp3lib libac3 libmpeg2 opendivx encore libvo libao2 loader loader/DirectShow drivers drivers/syncfb ; do $(MAKE) -C $$a distclean ; done
! 	rm -f *~ $(PRG) $(PRG_FIBMAP) $(PRG_HQ) $(PRG_AVIP) $(PRG_TV) $(OBJS) *.o *.a .depend
  
  dep:	depend

Index: dvdauth.c
===================================================================
RCS file: /cvsroot/mplayer/main/dvdauth.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** dvdauth.c	2001/06/06 21:16:21	1.5
--- dvdauth.c	2001/06/18 23:56:19	1.6
***************
*** 14,17 ****
--- 14,18 ----
  #include <sys/ioctl.h>
  #include <sys/stat.h>
+ #include <sys/wait.h>
  #include <css.h>
  #if CSS_MAJOR_VERSION > 0 || (CSS_MAJOR_VERSION == 0 && CSS_MINOR_VERSION > 1)
***************
*** 47,52 ****
  #define	CSSDVDisEncrypted(hdl)	CSSisEncrypted(hdl)
  #define	CSSDVDAuthDisc		CSSAuthDisc
! #define	CSSDVDAuthTitlePath(hdl,key_title,path) \
! 		CSSAuthTitle(hdl,key_title,path_to_lba(path))
  
  #else	/*OLD_CSS_API*/
--- 48,55 ----
  #define	CSSDVDisEncrypted(hdl)	CSSisEncrypted(hdl)
  #define	CSSDVDAuthDisc		CSSAuthDisc
! /* Arghhh! Please think before you commit! You forget to check the return
!    value of path_to_lba (-1 for error) in this way ... - LGB */
! //#define	CSSDVDAuthTitlePath(hdl,key_title,path) \
! //		CSSAuthTitle(hdl,key_title,path_to_lba(path))
  
  #else	/*OLD_CSS_API*/
***************
*** 59,62 ****
--- 62,67 ----
  
  char *dvd_auth_device=NULL;
+ char *dvd_device=NULL;
+ char *dvd_raw_device=NULL;
  unsigned char key_disc[2048];
  unsigned char key_title[5];
***************
*** 80,101 ****
  static int path_to_lba (char *path)
  {
!     int fd, lba = 0;
! 
!     if ((fd = open(path, O_RDONLY)) == -1) {
!         fprintf(stderr, "Cannot open file %s: %s",
! 		path ? path : "(NULL)", strerror(errno));
!         return -1;
      }
!     if (ioctl(fd, FIBMAP, &lba) != 0) {
!         perror ("ioctl FIBMAP");
! 	fprintf(stderr,"Hint: run mplayer as root!\n");
!         close(fd);
!         return -1;
      }
! 
!     close(fd);
! 
      return lba;
  }
  #else /*linux*/
  static int path_to_lba (char *path)
--- 85,134 ----
  static int path_to_lba (char *path)
  {
!     int lba = 0;
!     char cmd[100];
!     FILE *fp;
! 
!     snprintf(cmd,sizeof(cmd),"fibmap_mplayer %s",path);
!     fp=popen(cmd,"r");
!     if (fp) {
! 	    int ret;
! 	    bzero(cmd,sizeof(cmd));
! 	    fgets(cmd,99,fp);
! 	    if ((ret=pclose(fp)))
! 		    fprintf(stderr,"fibmap_mplayer: %s\n",*cmd?cmd:"no error info");
! 	    if(WIFEXITED(ret) && !WEXITSTATUS(ret)) 
! 		lba=atoi(cmd);
! 	    else
! 		fp=NULL;
      }
!     if (!fp) {
! 	int fd;
! 	printf("fibmap_mplayer could not run, trying with ioctl() ...\n");
! 	if ((fd = open(path, O_RDONLY)) == -1) {
!     	    fprintf(stderr, "Cannot open file %s: %s",
! 	    path ? path : "(NULL)", strerror(errno));
!     	    return -1;
! 	}
!         if (ioctl(fd, FIBMAP, &lba) != 0) {
!             perror ("ioctl FIBMAP");
! 	    fprintf(stderr,"Hint: run mplayer as root (or better to install fibmap_mplayer as suid root)!\n");
!             close(fd);
!             return -1;
!         }
! 	close(fd);
      }
!     printf("LBA: %d\n",lba);
      return lba;
  }
+ 
+ 
+ int CSSDVDAuthTitlePath(DVDHandle hdl,unsigned char *key_title,char *path)
+ {
+ 	int lba=path_to_lba(path);
+ 	if (lba==-1) return -1;
+ 	return CSSAuthTitle(hdl,key_title,lba);
+ }		
+ 		
+ 
  #else /*linux*/
  static int path_to_lba (char *path)


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list