Mercurial > mplayer.hg
annotate libmpdemux/dvdauth.c @ 6069:8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
author | albeu |
---|---|
date | Mon, 13 May 2002 13:15:40 +0000 |
parents | 02576893af2a |
children | ad967766679a |
rev | line source |
---|---|
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
1 /* (C)2001,2002 by LGB (Gabor Lenart), based on example programs in libcss |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
2 lgb@lgb.hu |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
3 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
4 This source is part of MPlayer project. This source is copyrighted by |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
5 the author according to rules declared in GNU/GPL license. |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
6 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
7 2001 Inital version (LGB) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
8 2001 fibmap_mplayer to avoid uid=0 mplayer need (LGB) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
9 2001 Support for libcss with the new API (by ???) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
10 2002/Jan/04 Use dlopen to access libcss.so to avoid conflict with |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
11 libdvdread [now with only libcss with old API (LGB) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
12 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
13 TODO: |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
14 support for libcss libraries with new API */ |
492 | 15 |
16 /* don't do anything with this source if css support was not requested */ | |
17 #include "config.h" | |
18 #ifdef HAVE_LIBCSS | |
19 | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
20 #warning FIXME: Dynamic loading of libcss.so with newer (ver>0.1) libcss API is not supported in this version! |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
21 |
492 | 22 #include <stdio.h> |
23 #include <stdlib.h> | |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
24 //#include <string.h> // FIXME: conflicts with fs.h |
1510
9ffe6c1a33b9
In case the open on the dvd device fails, print some hints based on errno
jkeil
parents:
1177
diff
changeset
|
25 #include <errno.h> |
492 | 26 #include <unistd.h> |
27 #include <fcntl.h> | |
28 #include <sys/types.h> | |
29 #include <sys/ioctl.h> | |
30 #include <sys/stat.h> | |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
31 #include <sys/wait.h> |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
32 // #include <css.h> |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
33 |
5872 | 34 #if defined(__FreeBSD__) || defined(__NetBSD__) |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
35 # include <sys/dvdio.h> |
5872 | 36 #elif defined(__OpenBSD__) |
37 # include <sys/cdio.h> | |
38 # define RTLD_NOW RTLD_LAZY | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
39 #elif defined(__linux__) |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
40 # include <linux/cdrom.h> |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
41 #elif defined(__sun) |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
42 # include <sun/dvdio.h> |
4128
f22ecf05acea
patch by Steven M. Schultz to support dvd under BSD/OS
alex
parents:
4093
diff
changeset
|
43 #elif defined(__bsdi__) |
f22ecf05acea
patch by Steven M. Schultz to support dvd under BSD/OS
alex
parents:
4093
diff
changeset
|
44 # include <dvd.h> |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
45 #else |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
46 # error "Need the DVD ioctls" |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
47 #endif |
492 | 48 |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
49 #include <dlfcn.h> |
492 | 50 #include "dvdauth.h" |
51 | |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
52 |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
53 // #if OLD_CSS_API |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
54 /* |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
55 * provide some backward compatibiliy macros to compile this |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
56 * code using the old libcss-0.1 |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
57 */ |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
58 #define DVDHandle int |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
59 #define DVDOpenFailed (-1) |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
60 |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
61 #define DVDAuth(hdl, s) ioctl(hdl, DVD_AUTH, s) |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
62 #define DVDOpenDevice(path) open(path, O_RDONLY) |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
63 #define DVDCloseDevice(hdl) close(hdl) |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
64 // #define CSSDVDisEncrypted(hdl) CSSisEncrypted(hdl) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
65 // #define CSSDVDAuthDisc CSSAuthDisc |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
66 |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
67 |
1018
e5fc7ec51fa3
-dvd is renamed to -dvdauth, variable dvd_device is renamed to dvd_auth_device. These changes are needed for future DVD playback developmenting
lgb
parents:
559
diff
changeset
|
68 char *dvd_auth_device=NULL; |
4228 | 69 extern char *dvd_device; |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
70 char *dvd_raw_device=NULL; |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
71 char *css_so=NULL; |
492 | 72 unsigned char key_disc[2048]; |
73 unsigned char key_title[5]; | |
546 | 74 unsigned char *dvdimportkey=NULL; |
75 int descrambling=0; | |
492 | 76 |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
77 static void *dlid; |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
78 static int (*dl_CSSisEncrypted)(int); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
79 static int (*dl_CSSAuthDisc)(int,char *); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
80 static int (*dl_CSSAuthTitle)(int, char *,int); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
81 static int (*dl_CSSGetASF)(int); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
82 static int (*dl_CSSDecryptTitleKey)(char *, char *); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
83 static void (*dl_CSSDescramble)(u_char *, u_char *); |
492 | 84 |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
85 dvd_css_descramble ( u_char *sec , u_char *key ) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
86 { |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
87 (*dl_CSSDescramble)(sec,key); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
88 } |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
89 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
90 |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
91 #ifdef __linux__ |
492 | 92 #include <linux/fs.h> |
93 | |
94 #ifndef FIBMAP | |
95 #define FIBMAP 1 | |
96 #endif | |
97 | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
98 |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
99 static int path_to_lba (char *path) |
492 | 100 { |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
101 int lba = 0; |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
102 char cmd[100]; |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
103 FILE *fp; |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
104 |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
105 snprintf(cmd,sizeof(cmd),"fibmap_mplayer %s",path); |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
106 fp=popen(cmd,"r"); |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
107 if (fp) { |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
108 int ret; |
3700 | 109 memset(cmd,0,sizeof(cmd)); |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
110 fgets(cmd,99,fp); |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
111 // printf("DVD: cmd: %s\n",cmd); |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
112 if ((ret=pclose(fp))) |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
113 fprintf(stderr,"DVD: fibmap_mplayer: %s\n",*cmd?cmd:"no error info"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
114 if (cmd[0]<'0'||cmd[0]>'9') fp=NULL; else { |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
115 if(WIFEXITED(ret) && !WEXITSTATUS(ret)) { |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
116 lba=atoi(cmd); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
117 printf("DVD: fibmap_mplayer is being used\n"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
118 } else |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
119 fp=NULL; |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
120 } |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
121 } |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
122 if (!fp) { |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
123 int fd; |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
124 printf("DVD: fibmap_mplayer could not run, trying with ioctl() ...\n"); |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
125 if ((fd = open(path, O_RDONLY)) == -1) { |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
126 fprintf(stderr, "DVD: Cannot open file %s: %s", |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
127 path ? path : "(NULL)", strerror(errno)); |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
128 return -1; |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
129 } |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
130 if (ioctl(fd, FIBMAP, &lba) != 0) { |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
131 perror("DVD: ioctl FIBMAP"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
132 fprintf(stderr," Hint: run mplayer as root (or better to install fibmap_mplayer as suid root)!\n"); |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
133 close(fd); |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
134 return -1; |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
135 } |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
136 close(fd); |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
137 } |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
138 printf("DVD: LBA: %d\n",lba); |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
139 return lba; |
492 | 140 } |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
141 |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
142 #else /*linux*/ |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
143 |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
144 static int path_to_lba (char *path) |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
145 { |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
146 #warning translating pathname to iso9660 LBA is not supported on this platform |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
147 fprintf(stderr, "DVD: Translating pathname to iso9660 LBA is not supported on this platform\n"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
148 return -1; |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
149 } |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
150 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
151 #endif /*linux*/ |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
152 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
153 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
154 static int CSSDVDAuthTitlePath(DVDHandle hdl,unsigned char *key_title,char *path) |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
155 { |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
156 int lba=path_to_lba(path); |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
157 if (lba==-1) return -1; |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
158 return (*dl_CSSAuthTitle)(hdl,key_title,lba); |
1163
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
159 } |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
160 |
ac1341d4a2a7
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 ;-)
lgb
parents:
1042
diff
changeset
|
161 |
492 | 162 |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
163 static void reset_agids ( DVDHandle dvd ) |
492 | 164 { |
4337 | 165 #if !defined(DVD_AUTH) && defined(DVDIOCREPORTKEY) |
166 struct dvd_authinfo ai; | |
167 int i; | |
168 for (i = 0; i < 4; i++) { | |
169 memset(&ai, 0, sizeof(ai)); | |
170 ai.format = DVD_INVALIDATE_AGID; | |
171 ai.agid = i; | |
172 ioctl(dvd, DVDIOCREPORTKEY, &ai); | |
173 } | |
174 #else | |
5872 | 175 #if defined(__OpenBSD__) |
176 union | |
177 #endif | |
492 | 178 dvd_authinfo ai; |
179 int i; | |
180 for (i = 0; i < 4; i++) { | |
181 memset(&ai, 0, sizeof(ai)); | |
182 ai.type = DVD_INVALIDATE_AGID; | |
183 ai.lsa.agid = i; | |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
184 DVDAuth(dvd, &ai); |
492 | 185 } |
4337 | 186 #endif |
492 | 187 } |
188 | |
189 | |
546 | 190 int dvd_import_key ( unsigned char *hexkey ) |
191 { | |
192 unsigned char *t=key_title; | |
193 int digit=4,len; | |
3700 | 194 memset(key_title,0,sizeof(key_title)); |
546 | 195 // printf("DVD key: %s\n",hexkey); |
196 for (len=0;len<10;len++) { | |
197 // printf("-> %c\n",*hexkey); | |
198 if (!*hexkey) return 1; | |
199 if (*hexkey>='A'&&*hexkey<='F') *t|=(*hexkey-'A'+10)<<digit; | |
200 else if (*hexkey>='0'&&*hexkey<='9') *t|=(*hexkey-'0')<<digit; | |
201 else return 1; | |
202 if (digit) digit=0; else { | |
203 digit=4; | |
204 t++; | |
205 } | |
206 hexkey++; | |
207 } | |
208 if (*hexkey) return 1; | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
209 printf("DVD: DVD key (requested): %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]); |
546 | 210 descrambling=1; |
211 return 0; | |
212 } | |
213 | |
492 | 214 |
559 | 215 |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
216 int dvd_auth ( char *dev , char *filename ) |
492 | 217 { |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
218 DVDHandle dvd; /* DVD device handle */ |
492 | 219 |
4093
d197584460dc
relatiev path to libcss.so - patch by Jim Radford <radford@robotics.caltech.edu>
arpi
parents:
3975
diff
changeset
|
220 if (!css_so) css_so=strdup("libcss.so"); |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
221 printf("DVD: opening libcss.so as %s ...\n",css_so); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
222 dlid=dlopen(css_so,RTLD_NOW); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
223 if (!dlid) { |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
224 printf("DVD: dlopen: %s\n",dlerror()); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
225 return 1; |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
226 } printf("DVD: dlopen OK!\n"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
227 |
5872 | 228 #ifdef __OpenBSD__ |
229 #define CSS_DLSYM(v,s) if (!(v=dlsym(dlid,"_" s))) {\ | |
230 fprintf(stderr,"DVD: %s\n Hint: use libcss version 0.1!\n",dlerror());\ | |
231 return 1; } | |
232 #else | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
233 #define CSS_DLSYM(v,s) if (!(v=dlsym(dlid,s))) {\ |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
234 fprintf(stderr,"DVD: %s\n Hint: use libcss version 0.1!\n",dlerror());\ |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
235 return 1; } |
5872 | 236 #endif |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
237 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
238 CSS_DLSYM(dl_CSSisEncrypted,"CSSisEncrypted"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
239 CSS_DLSYM(dl_CSSAuthDisc,"CSSAuthDisc"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
240 CSS_DLSYM(dl_CSSAuthTitle,"CSSAuthTitle"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
241 CSS_DLSYM(dl_CSSGetASF,"CSSGetASF"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
242 CSS_DLSYM(dl_CSSDecryptTitleKey,"CSSDecryptTitleKey"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
243 CSS_DLSYM(dl_CSSDescramble,"CSSDescramble"); |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
244 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
245 #undef CSS_DLSYM |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
246 |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
247 if ((dvd=DVDOpenDevice(dev)) == DVDOpenFailed) { |
1510
9ffe6c1a33b9
In case the open on the dvd device fails, print some hints based on errno
jkeil
parents:
1177
diff
changeset
|
248 fprintf(stderr,"DVD: cannot open DVD device \"%s\": %s.\n", |
9ffe6c1a33b9
In case the open on the dvd device fails, print some hints based on errno
jkeil
parents:
1177
diff
changeset
|
249 dev, strerror(errno)); |
492 | 250 return 1; |
251 } | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
252 |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
253 if (!(*dl_CSSisEncrypted)(dvd)) { |
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
254 printf("DVD: DVD is unencrypted! Skipping authentication!\n(note: you should not use -dvd switch for unencrypted discs!)\n"); |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
255 DVDCloseDevice(dvd); |
559 | 256 return 0; |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
257 } else printf("DVD: DVD is encrypted, issuing authentication ...\n"); |
492 | 258 /* reset AGIDs */ |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
259 reset_agids(dvd); |
492 | 260 /* authenticate disc */ |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
261 if ((*dl_CSSAuthDisc)(dvd,key_disc)) { |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
262 fprintf(stderr,"DVD: CSSDVDAuthDisc() failed.\n"); |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
263 DVDCloseDevice(dvd); |
492 | 264 return 1; |
265 } | |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
266 if (CSSDVDAuthTitlePath(dvd,key_title,filename)) { |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
267 fprintf(stderr,"DVD: CSSDVDAuthTitle() failed.\n"); |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
268 DVDCloseDevice(dvd); |
492 | 269 return 1; |
270 } | |
271 | |
272 /* decrypting title */ | |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
273 if ((*dl_CSSDecryptTitleKey)(key_title, key_disc) < 0) { |
492 | 274 fprintf(stderr,"DVD: CSSDecryptTitleKey() failed.\n"); |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
275 DVDCloseDevice(dvd); |
492 | 276 return 1; |
277 } | |
278 | |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1018
diff
changeset
|
279 DVDCloseDevice(dvd); |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3700
diff
changeset
|
280 printf("DVD: DVD title key is: %02X%02X%02X%02X%02X\n",key_title[0],key_title[1],key_title[2],key_title[3],key_title[4]); |
546 | 281 descrambling=1; |
492 | 282 return 0; |
283 } | |
284 | |
285 | |
286 #endif |