]> git.sesse.net Git - vlc/blob - src/misc/update.c
utf8_* -> vlc_* (sed roxxors)
[vlc] / src / misc / update.c
1 /*****************************************************************************
2  * update.c: VLC update checking and downloading
3  *****************************************************************************
4  * Copyright © 2005-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *          Rémi Duraffort <ivoire at via.ecp.fr>
9             Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either release 2 of the License, or
14  * (at your option) any later release.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /**
27  *   \file
28  *   This file contains functions related to VLC update management
29  */
30
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/
34
35 #ifdef HAVE_CONFIG_H
36 # include "config.h"
37 #endif
38
39 #include <vlc_common.h>
40 #include <vlc_update.h>
41
42 #ifdef UPDATE_CHECK
43
44 #include <assert.h>
45
46 #include <vlc_pgpkey.h>
47 #include <vlc_stream.h>
48 #include <vlc_strings.h>
49 #include <vlc_fs.h>
50 #include <vlc_dialog.h>
51
52 #include <gcrypt.h>
53 #include <vlc_gcrypt.h>
54
55 #include "update.h"
56 #include "../libvlc.h"
57
58 /*****************************************************************************
59  * Misc defines
60  *****************************************************************************/
61
62 /*
63  * Here is the format of these "status files" :
64  * First line is the last version: "X.Y.Ze" where:
65  *      * X is the major number
66  *      * Y is the minor number
67  *      * Z is the revision number
68  *      * e is an OPTIONAL extra letter
69  *      * AKA "0.8.6d" or "0.9.0"
70  * Second line is an url of the binary for this last version
71  * Remaining text is a required description of the update
72  */
73
74 #if defined( UNDER_CE )
75 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-ce"
76 #elif defined( WIN32 )
77 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-win-x86"
78 #elif defined( __APPLE__ )
79 #   if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
80 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-ppc"
81 #   else
82 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-x86"
83 #   endif
84 #elif defined( SYS_BEOS )
85 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-beos-x86"
86 #else
87 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status"
88 #endif
89
90
91 /*****************************************************************************
92  * Update_t functions
93  *****************************************************************************/
94
95 #undef update_New
96 /**
97  * Create a new update VLC struct
98  *
99  * \param p_this the calling vlc_object
100  * \return pointer to new update_t or NULL
101  */
102 update_t *update_New( vlc_object_t *p_this )
103 {
104     update_t *p_update;
105     assert( p_this );
106
107     p_update = (update_t *)malloc( sizeof( update_t ) );
108     if( !p_update ) return NULL;
109
110     vlc_mutex_init( &p_update->lock );
111
112     p_update->p_libvlc = p_this->p_libvlc;
113
114     p_update->release.psz_url = NULL;
115     p_update->release.psz_desc = NULL;
116
117     p_update->p_download = NULL;
118     p_update->p_check = NULL;
119
120     p_update->p_pkey = NULL;
121     vlc_gcrypt_init();
122
123     return p_update;
124 }
125
126 /**
127  * Delete an update_t struct
128  *
129  * \param p_update update_t* pointer
130  * \return nothing
131  */
132 void update_Delete( update_t *p_update )
133 {
134     assert( p_update );
135
136     if( p_update->p_check )
137     {
138         vlc_object_kill( p_update->p_check );
139         vlc_thread_join( p_update->p_check );
140         vlc_object_release( p_update->p_check );
141     }
142
143     if( p_update->p_download )
144     {
145         vlc_object_kill( p_update->p_download );
146         vlc_thread_join( p_update->p_download );
147         vlc_object_release( p_update->p_download );
148     }
149
150     vlc_mutex_destroy( &p_update->lock );
151
152     free( p_update->release.psz_url );
153     free( p_update->release.psz_desc );
154     free( p_update->p_pkey );
155
156     free( p_update );
157 }
158
159 /**
160  * Empty the release struct
161  *
162  * \param p_update update_t* pointer
163  * \return nothing
164  */
165 static void EmptyRelease( update_t *p_update )
166 {
167     p_update->release.i_major = 0;
168     p_update->release.i_minor = 0;
169     p_update->release.i_revision = 0;
170
171     FREENULL( p_update->release.psz_url );
172     FREENULL( p_update->release.psz_desc );
173 }
174
175 /**
176  * Get the update file and parse it
177  * p_update has to be locked when calling this function
178  *
179  * \param p_update pointer to update struct
180  * \return true if the update is valid and authenticated
181  */
182 static bool GetUpdateFile( update_t *p_update )
183 {
184     stream_t *p_stream = NULL;
185     int i_major = 0;
186     int i_minor = 0;
187     int i_revision = 0;
188     unsigned char extra;
189     char *psz_version_line = NULL;
190     char *psz_update_data = NULL;
191
192     p_stream = stream_UrlNew( p_update->p_libvlc, UPDATE_VLC_STATUS_URL );
193     if( !p_stream )
194     {
195         msg_Err( p_update->p_libvlc, "Failed to open %s for reading",
196                  UPDATE_VLC_STATUS_URL );
197         goto error;
198     }
199
200     const int64_t i_read = stream_Size( p_stream );
201     psz_update_data = malloc( i_read + 1 ); /* terminating '\0' */
202     if( !psz_update_data )
203         goto error;
204
205     if( stream_Read( p_stream, psz_update_data, i_read ) != i_read )
206     {
207         msg_Err( p_update->p_libvlc, "Couldn't download update file %s",
208                 UPDATE_VLC_STATUS_URL );
209         goto error;
210     }
211     psz_update_data[i_read] = '\0';
212
213     stream_Delete( p_stream );
214     p_stream = NULL;
215
216     /* first line : version number */
217     char *psz_update_data_parser = psz_update_data;
218     size_t i_len = strcspn( psz_update_data, "\r\n" );
219     psz_update_data_parser += i_len;
220     while( *psz_update_data_parser == '\r' || *psz_update_data_parser == '\n' )
221         psz_update_data_parser++;
222
223     if( !(psz_version_line = malloc( i_len + 1)) )
224         goto error;
225     strncpy( psz_version_line, psz_update_data, i_len );
226     psz_version_line[i_len] = '\0';
227
228     p_update->release.extra = 0;
229     switch( sscanf( psz_version_line, "%i.%i.%i%c",
230                     &i_major, &i_minor, &i_revision, &extra ) )
231     {
232         case 4:
233             p_update->release.extra = extra;
234         case 3:
235             p_update->release.i_major = i_major;
236             p_update->release.i_minor = i_minor;
237             p_update->release.i_revision = i_revision;
238             break;
239         default:
240             msg_Err( p_update->p_libvlc, "Update version false formated" );
241             goto error;
242     }
243
244     /* second line : URL */
245     i_len = strcspn( psz_update_data_parser, "\r\n" );
246     if( i_len == 0 )
247     {
248         msg_Err( p_update->p_libvlc, "Update file %s is corrupted: URL missing",
249                  UPDATE_VLC_STATUS_URL );
250
251         goto error;
252     }
253
254     if( !(p_update->release.psz_url = malloc( i_len + 1)) )
255         goto error;
256     strncpy( p_update->release.psz_url, psz_update_data_parser, i_len );
257     p_update->release.psz_url[i_len] = '\0';
258
259     psz_update_data_parser += i_len;
260     while( *psz_update_data_parser == '\r' || *psz_update_data_parser == '\n' )
261         psz_update_data_parser++;
262
263     /* Remaining data : description */
264     i_len = strlen( psz_update_data_parser );
265     if( i_len == 0 )
266     {
267         msg_Err( p_update->p_libvlc,
268                 "Update file %s is corrupted: description missing",
269                 UPDATE_VLC_STATUS_URL );
270         goto error;
271     }
272
273     if( !(p_update->release.psz_desc = malloc( i_len + 1)) )
274         goto error;
275     strncpy( p_update->release.psz_desc, psz_update_data_parser, i_len );
276     p_update->release.psz_desc[i_len] = '\0';
277
278     printf("desc %s\n", p_update->release.psz_desc);
279
280     /* Now that we know the status is valid, we must download its signature
281      * to authenticate it */
282     signature_packet_t sign;
283     if( download_signature( VLC_OBJECT( p_update->p_libvlc ), &sign,
284             UPDATE_VLC_STATUS_URL ) != VLC_SUCCESS )
285     {
286         msg_Err( p_update->p_libvlc, "Couldn't download signature of status file" );
287         goto error;
288     }
289
290     if( sign.type != BINARY_SIGNATURE && sign.type != TEXT_SIGNATURE )
291     {
292         msg_Err( p_update->p_libvlc, "Invalid signature type" );
293         goto error;
294     }
295
296     p_update->p_pkey = (public_key_t*)malloc( sizeof( public_key_t ) );
297     if( !p_update->p_pkey )
298         goto error;
299
300     if( parse_public_key( videolan_public_key, sizeof( videolan_public_key ),
301                         p_update->p_pkey, NULL ) != VLC_SUCCESS )
302     {
303         msg_Err( p_update->p_libvlc, "Couldn't parse embedded public key, something went really wrong..." );
304         FREENULL( p_update->p_pkey );
305         goto error;
306     }
307
308     memcpy( p_update->p_pkey->longid, videolan_public_key_longid, 8 );
309
310     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid , 8 ) != 0 )
311     {
312         msg_Dbg( p_update->p_libvlc, "Need to download the GPG key" );
313         public_key_t *p_new_pkey = download_key(
314                 VLC_OBJECT(p_update->p_libvlc),
315                 sign.issuer_longid, videolan_public_key_longid );
316         if( !p_new_pkey )
317         {
318             msg_Err( p_update->p_libvlc, "Couldn't download GPG key" );
319             FREENULL( p_update->p_pkey );
320             goto error;
321         }
322
323         uint8_t *p_hash = hash_sha1_from_public_key( p_new_pkey );
324         if( !p_hash )
325         {
326             msg_Err( p_update->p_libvlc, "Failed to hash signature" );
327             free( p_new_pkey );
328             FREENULL( p_update->p_pkey );
329             goto error;
330         }
331
332         if( verify_signature( p_new_pkey->sig.r, p_new_pkey->sig.s,
333                     &p_update->p_pkey->key, p_hash ) == VLC_SUCCESS )
334         {
335             free( p_hash );
336             msg_Info( p_update->p_libvlc, "Key authenticated" );
337             free( p_update->p_pkey );
338             p_update->p_pkey = p_new_pkey;
339         }
340         else
341         {
342             free( p_hash );
343             msg_Err( p_update->p_libvlc, "Key signature invalid !\n" );
344             goto error;
345         }
346     }
347
348     uint8_t *p_hash = hash_sha1_from_text( psz_update_data, &sign );
349     if( !p_hash )
350     {
351         msg_Warn( p_update->p_libvlc, "Can't compute SHA1 hash for status file" );
352         goto error;
353     }
354
355     else if( p_hash[0] != sign.hash_verification[0] ||
356         p_hash[1] != sign.hash_verification[1] )
357     {
358         msg_Warn( p_update->p_libvlc, "Bad SHA1 hash for status file" );
359         goto error;
360     }
361
362     else if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
363             != VLC_SUCCESS )
364     {
365         msg_Err( p_update->p_libvlc, "BAD SIGNATURE for status file" );
366         goto error;
367     }
368
369     else
370     {
371         msg_Info( p_update->p_libvlc, "Status file authenticated" );
372         return true;
373     }
374
375 error:
376     if( p_stream )
377         stream_Delete( p_stream );
378     free( psz_version_line );
379     free( psz_update_data );
380     return false;
381 }
382
383 static void* update_CheckReal( vlc_object_t *p_this );
384
385 /**
386  * Check for updates
387  *
388  * \param p_update pointer to update struct
389  * \param pf_callback pointer to a function to call when the update_check is finished
390  * \param p_data pointer to some datas to give to the callback
391  * \returns nothing
392  */
393 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ), void *p_data )
394 {
395     assert( p_update );
396
397     // If the object already exist, destroy it
398     if( p_update->p_check )
399     {
400         vlc_object_kill( p_update->p_check );
401         vlc_thread_join( p_update->p_check );
402         vlc_object_release( p_update->p_check );
403     }
404
405     update_check_thread_t *p_uct =
406         vlc_custom_create( p_update->p_libvlc, sizeof( *p_uct ),
407                            VLC_OBJECT_GENERIC, "update check" );
408     if( !p_uct ) return;
409
410     p_uct->p_update = p_update;
411     p_update->p_check = p_uct;
412     p_uct->pf_callback = pf_callback;
413     p_uct->p_data = p_data;
414
415     vlc_thread_create( p_uct, "check for update", update_CheckReal,
416                        VLC_THREAD_PRIORITY_LOW );
417 }
418
419 void* update_CheckReal( vlc_object_t* p_this )
420 {
421     update_check_thread_t *p_uct = (update_check_thread_t *)p_this;
422     bool b_ret;
423     int canc;
424
425     canc = vlc_savecancel ();
426     vlc_mutex_lock( &p_uct->p_update->lock );
427
428     EmptyRelease( p_uct->p_update );
429     b_ret = GetUpdateFile( p_uct->p_update );
430     vlc_mutex_unlock( &p_uct->p_update->lock );
431
432     if( p_uct->pf_callback )
433         (p_uct->pf_callback)( p_uct->p_data, b_ret );
434
435     vlc_restorecancel (canc);
436     return NULL;
437 }
438
439 /**
440  * Compare a given release's version number to the current VLC's one
441  *
442  * \param p_update structure
443  * \return true if we have to upgrade to the given version to be up to date
444  */
445 static bool is_strictly_greater( int * a, int * b, int n)
446 {
447     if( n <= 0 ) return false;
448     if(a[0] > b[0] ) return true;
449     if(a[0] == b[0] ) return is_strictly_greater( a+1, b+1, n-1 );
450     /* a[0] < b[0] */ return false;
451 }
452
453 bool update_NeedUpgrade( update_t *p_update )
454 {
455     assert( p_update );
456
457     int current_version[] = {
458         *PACKAGE_VERSION_MAJOR - '0',
459         *PACKAGE_VERSION_MINOR - '0',
460         *PACKAGE_VERSION_REVISION - '0',
461         /* extra string of development versions is "-git", "-rc" ..
462          * so make sure version a.b.c is newer than a.b.c-XXX */
463         (*PACKAGE_VERSION_EXTRA == '-') ? -1 : *PACKAGE_VERSION_EXTRA
464     };
465     int latest_version[] = {
466         p_update->release.i_major,
467         p_update->release.i_minor,
468         p_update->release.i_revision,
469         p_update->release.extra
470     };
471
472     return is_strictly_greater( latest_version, current_version, 4 );
473 }
474
475 /**
476  * Convert a long int size in bytes to a string
477  *
478  * \param l_size the size in bytes
479  * \return the size as a string
480  */
481 static char *size_str( long int l_size )
482 {
483     char *psz_tmp = NULL;
484     int i_retval = 0;
485     if( l_size >> 30 )
486         i_retval = asprintf( &psz_tmp, _("%.1f GB"), (float)l_size/(1<<30) );
487     else if( l_size >> 20 )
488         i_retval = asprintf( &psz_tmp, _("%.1f MB"), (float)l_size/(1<<20) );
489     else if( l_size >> 10 )
490         i_retval = asprintf( &psz_tmp, _("%.1f kB"), (float)l_size/(1<<10) );
491     else
492         i_retval = asprintf( &psz_tmp, _("%ld B"), l_size );
493
494     return i_retval == -1 ? NULL : psz_tmp;
495 }
496
497 static void* update_DownloadReal( vlc_object_t *p_this );
498
499 /**
500  * Download the file given in the update_t
501  *
502  * \param p_update structure
503  * \param dir to store the download file
504  * \return nothing
505  */
506 void update_Download( update_t *p_update, const char *psz_destdir )
507 {
508     assert( p_update );
509
510     // If the object already exist, destroy it
511     if( p_update->p_download )
512     {
513         vlc_object_kill( p_update->p_download );
514         vlc_thread_join( p_update->p_download );
515         vlc_object_release( p_update->p_download );
516     }
517
518     update_download_thread_t *p_udt =
519         vlc_custom_create( p_update->p_libvlc, sizeof( *p_udt ),
520                            VLC_OBJECT_GENERIC, "update download" );
521     if( !p_udt )
522         return;
523
524     p_udt->p_update = p_update;
525     p_update->p_download = p_udt;
526     p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
527
528     vlc_thread_create( p_udt, "download update", update_DownloadReal,
529                        VLC_THREAD_PRIORITY_LOW );
530 }
531
532 static void* update_DownloadReal( vlc_object_t *p_this )
533 {
534     update_download_thread_t *p_udt = (update_download_thread_t *)p_this;
535     dialog_progress_bar_t *p_progress = NULL;
536     long int l_size;
537     long int l_downloaded = 0;
538     float f_progress;
539     char *psz_status = NULL;
540     char *psz_downloaded = NULL;
541     char *psz_size = NULL;
542     char *psz_destfile = NULL;
543     char *psz_tmpdestfile = NULL;
544
545     FILE *p_file = NULL;
546     stream_t *p_stream = NULL;
547     void* p_buffer = NULL;
548     int i_read;
549     int canc;
550
551     update_t *p_update = p_udt->p_update;
552     char *psz_destdir = p_udt->psz_destdir;
553
554     msg_Dbg( p_udt, "Opening Stream '%s'", p_update->release.psz_url );
555     canc = vlc_savecancel ();
556
557     /* Open the stream */
558     p_stream = stream_UrlNew( p_udt, p_update->release.psz_url );
559     if( !p_stream )
560     {
561         msg_Err( p_udt, "Failed to open %s for reading", p_update->release.psz_url );
562         goto end;
563     }
564
565     /* Get the stream size */
566     l_size = stream_Size( p_stream );
567
568     /* Get the file name and open it*/
569     psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );
570     if( !psz_tmpdestfile )
571     {
572         msg_Err( p_udt, "The URL %s is badly formated",
573                  p_update->release.psz_url );
574         goto end;
575     }
576     psz_tmpdestfile++;
577     if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 )
578         goto end;
579
580     p_file = vlc_fopen( psz_destfile, "w" );
581     if( !p_file )
582     {
583         msg_Err( p_udt, "Failed to open %s for writing", psz_destfile );
584         dialog_FatalWait( p_udt, _("Saving file failed"),
585             _("Failed to open \"%s\" for writing"),
586              psz_destfile );
587         goto end;
588     }
589
590     /* Create a buffer and fill it with the downloaded file */
591     p_buffer = (void *)malloc( 1 << 10 );
592     if( !p_buffer )
593     {
594         msg_Err( p_udt, "Can't malloc (1 << 10) bytes! download cancelled." );
595         goto end;
596     }
597
598     msg_Dbg( p_udt, "Downloading Stream '%s'", p_update->release.psz_url );
599
600     psz_size = size_str( l_size );
601     if( asprintf( &psz_status, _("%s\nDownloading... %s/%s %.1f%% done"),
602         p_update->release.psz_url, "0.0", psz_size, 0.0 ) != -1 )
603     {
604         p_progress = dialog_ProgressCreate( p_udt, _( "Downloading ..."),
605                                             psz_status, _("Cancel") );
606         free( psz_status );
607     }
608
609     while( vlc_object_alive( p_udt ) &&
610            ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
611            !dialog_ProgressCancelled( p_progress ) )
612     {
613         if( fwrite( p_buffer, i_read, 1, p_file ) < 1 )
614         {
615             msg_Err( p_udt, "Failed to write into %s", psz_destfile );
616             break;
617         }
618
619         l_downloaded += i_read;
620         psz_downloaded = size_str( l_downloaded );
621         f_progress = (float)l_downloaded/(float)l_size;
622
623         if( asprintf( &psz_status, _( "%s\nDownloading... %s/%s - %.1f%% done" ),
624                       p_update->release.psz_url, psz_downloaded, psz_size,
625                       f_progress*100 ) != -1 )
626         {
627             dialog_ProgressSet( p_progress, psz_status, f_progress );
628             free( psz_status );
629         }
630         free( psz_downloaded );
631     }
632
633     /* Finish the progress bar or delete the file if the user had canceled */
634     fclose( p_file );
635     p_file = NULL;
636
637     if( vlc_object_alive( p_udt ) &&
638         !dialog_ProgressCancelled( p_progress ) )
639     {
640         if( asprintf( &psz_status, _("%s\nDone %s (100.0%%)"),
641             p_update->release.psz_url, psz_size ) != -1 )
642         {
643             dialog_ProgressDestroy( p_progress );
644             p_progress = NULL;
645             free( psz_status );
646         }
647     }
648     else
649     {
650         vlc_unlink( psz_destfile );
651         goto end;
652     }
653
654     signature_packet_t sign;
655     if( download_signature( VLC_OBJECT( p_udt ), &sign,
656             p_update->release.psz_url ) != VLC_SUCCESS )
657     {
658         vlc_unlink( psz_destfile );
659
660         dialog_FatalWait( p_udt, _("File could not be verified"),
661             _("It was not possible to download a cryptographic signature for "
662               "the downloaded file \"%s\". Thus, it was deleted."),
663             psz_destfile );
664         msg_Err( p_udt, "Couldn't download signature of downloaded file" );
665         goto end;
666     }
667
668     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid, 8 ) )
669     {
670         vlc_unlink( psz_destfile );
671         msg_Err( p_udt, "Invalid signature issuer" );
672         dialog_FatalWait( p_udt, _("Invalid signature"),
673             _("The cryptographic signature for the downloaded file \"%s\" was "
674               "invalid and could not be used to securely verify it. Thus, the "
675               "file was deleted."),
676             psz_destfile );
677         goto end;
678     }
679
680     if( sign.type != BINARY_SIGNATURE )
681     {
682         vlc_unlink( psz_destfile );
683         msg_Err( p_udt, "Invalid signature type" );
684         dialog_FatalWait( p_udt, _("Invalid signature"),
685             _("The cryptographic signature for the downloaded file \"%s\" was "
686               "invalid and could not be used to securely verify it. Thus, the "
687               "file was deleted."),
688             psz_destfile );
689         goto end;
690     }
691
692     uint8_t *p_hash = hash_sha1_from_file( psz_destfile, &sign );
693     if( !p_hash )
694     {
695         msg_Err( p_udt, "Unable to hash %s", psz_destfile );
696         vlc_unlink( psz_destfile );
697         dialog_FatalWait( p_udt, _("File not verifiable"),
698             _("It was not possible to securely verify the downloaded file"
699               " \"%s\". Thus, it was deleted."),
700             psz_destfile );
701
702         goto end;
703     }
704
705     if( p_hash[0] != sign.hash_verification[0] ||
706         p_hash[1] != sign.hash_verification[1] )
707     {
708         vlc_unlink( psz_destfile );
709         dialog_FatalWait( p_udt, _("File corrupted"),
710             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
711              psz_destfile );
712         msg_Err( p_udt, "Bad SHA1 hash for %s", psz_destfile );
713         free( p_hash );
714         goto end;
715     }
716
717     if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
718             != VLC_SUCCESS )
719     {
720         vlc_unlink( psz_destfile );
721         dialog_FatalWait( p_udt, _("File corrupted"),
722             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
723              psz_destfile );
724         msg_Err( p_udt, "BAD SIGNATURE for %s", psz_destfile );
725         free( p_hash );
726         goto end;
727     }
728
729     msg_Info( p_udt, "%s authenticated", psz_destfile );
730     free( p_hash );
731
732 end:
733     if( p_progress )
734         dialog_ProgressDestroy( p_progress );
735     if( p_stream )
736         stream_Delete( p_stream );
737     if( p_file )
738         fclose( p_file );
739     free( psz_destdir );
740     free( psz_destfile );
741     free( p_buffer );
742     free( psz_size );
743
744     vlc_restorecancel( canc );
745     return NULL;
746 }
747
748 update_release_t *update_GetRelease( update_t *p_update )
749 {
750     return &p_update->release;
751 }
752
753 #else
754 #undef update_New
755 update_t *update_New( vlc_object_t *p_this )
756 {
757     (void)p_this;
758     return NULL;
759 }
760
761 void update_Delete( update_t *p_update )
762 {
763     (void)p_update;
764 }
765
766 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ),
767                    void *p_data )
768 {
769     (void)p_update; (void)pf_callback; (void)p_data;
770 }
771
772 bool update_NeedUpgrade( update_t *p_update )
773 {
774     (void)p_update;
775     return false;
776 }
777
778 void update_Download( update_t *p_update, const char *psz_destdir )
779 {
780     (void)p_update; (void)psz_destdir;
781 }
782
783 update_release_t *update_GetRelease( update_t *p_update )
784 {
785     (void)p_update;
786     return NULL;
787 }
788 #endif