Ticket #4860: mythtv-4860-scaled_preview_filesystem_permissions-makeFileAccessible-20080728-2.patch

File mythtv-4860-scaled_preview_filesystem_permissions-makeFileAccessible-20080728-2.patch, 3.6 KB (added by sphery <mtdean@…>, 16 years ago)

The correct updated patch ( mythtv-4860-scaled_preview_filesystem_permissions-makeFileAccessible-20080728.patch was missing a change)

  • libs/libmythtv/previewgenerator.cpp

     
    463463    QByteArray fname = filename.toAscii();
    464464    if (small_img.save(fname.constData(), "PNG"))
    465465    {
    466         chmod(fname.constData(), 0666); // Let anybody update it
     466        makeFileAccessible(fname.constData()); // Let anybody update it
    467467
    468468        VERBOSE(VB_PLAYBACK, LOC +
    469469                QString("Saved preview '%0' %1x%2")
     
    478478    if (QFileInfo(fname.constData()).exists() &&
    479479        small_img.save(newfilea.constData(), "PNG"))
    480480    {
    481         chmod(newfilea.constData(), 0666);
     481        makeFileAccessible(newfilea.constData());
    482482        rename(newfilea.constData(), fname.constData());
    483483
    484484        VERBOSE(VB_PLAYBACK, LOC +
  • libs/libmythtv/datadirect.cpp

     
    16391639
    16401640    VERBOSE(VB_GENERAL, "SaveLineupToCache("<<lineupid<<") -- success");
    16411641
    1642     chmod(fna.constData(), 0666); // Let anybody update it
     1642    makeFileAccessible(fna.constData()); // Let anybody update it
    16431643
    16441644    return true;
    16451645}
  • libs/libmyth/util.h

     
    5858MPUBLIC long long copy(QFile &dst, QFile &src, uint block_size = 0);
    5959MPUBLIC QString createTempFile(QString name_template = "/tmp/mythtv_XXXXXX",
    6060                               bool dir = false);
     61MPUBLIC void makeFileAccessible(QString filename);
    6162MPUBLIC unsigned long long myth_get_approximate_large_file_size(
    6263    const QString &fname);
    6364
  • libs/libmyth/util.cpp

     
    804804    return tmpFileName;
    805805}
    806806
     807/** \fn makeFileAccessible(QString)
     808 *  \brief Makes a file accessible to all frontends/backends.
     809 *
     810 *   This function abstracts the functionality of making a file accessible to
     811 *   all frontends and backends.  Currently it contains a permissions hack that
     812 *   makes a file accessible even on a system with an improperly configured
     813 *   environment (umask/group) where the frontend and backend are being run as
     814 *   different users or where a NFS share is used but UID's/GID's differ on
     815 *   different hosts.
     816 *
     817 *   Though the function currently only changes the file mode to 0666, by
     818 *   abstracting the functionality, it will be easier to make changes in the
     819 *   future if a better approach is chosen.  Similarly, using this function
     820 *   allows the hack to be applied only when required if code is written to
     821 *   detect or allow the user to specify their system is misconfigured.
     822 *
     823 *  \param filename   Path of file to make accessible
     824 */
     825void makeFileAccessible(QString filename)
     826{
     827    QByteArray fname = filename.toAscii();
     828    chmod(fname.constData(), 0666);
     829}
     830
    807831double MythGetPixelAspectRatio(void)
    808832{
    809833    float pixelAspect = 1.0;
  • programs/mythbackend/mythxml.cpp

     
    12361236    QByteArray fname = pRequest->m_sFileName.toAscii();
    12371237    img.save( fname.constData(), "PNG" );
    12381238
     1239    makeFileAccessible(fname.constData());
     1240
    12391241    delete pImage;
    12401242}
    12411243