Changeset aa7ba66


Ignore:
Timestamp:
01/07/14 14:21:24 (17 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, enter/10, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
6052403
Parents:
a7429d5 (diff), 8a4c7a0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:pcbsd/pcbsd

Files:
3 added
2 deleted
13 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-sysmanager/cmdDialog.cpp

    r8d1c3e0 r8a4c7a0  
    55  ui->setupUi(this); //load the designer UI file 
    66  //Setup the backend process class 
    7   PROC = new gitProc; 
     7  PROC = new LongProc; 
    88    connect(PROC, SIGNAL(ProcMessage(QString)), this, SLOT(NewMessage(QString)) ); 
    9     connect(PROC, SIGNAL(procFinished(bool)), this, SLOT(Finished(bool)) ); 
    10   //Setup internal flags 
    11   initPorts = false; initSource = false; //make sure these are both initially disabled 
    12   connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) );    
     9    connect(PROC, SIGNAL(ProcFinished()), this, SLOT(Finished()) ); 
     10  //Setup internal connections 
     11  connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) ); 
     12  connect(ui->push_stop, SIGNAL(clicked()), this, SLOT(stopProcess()) ); 
    1313} 
    1414 
     
    1717} 
    1818 
    19 void CMDDialog::start(QString cmdtype){ 
     19void CMDDialog::start(QString cmdtype, QString branch){ 
    2020  if(PROC->isRunning()){ 
    2121    qDebug() << "ERROR: Process is already working: please wait until it is finished"; 
     
    2323  } 
    2424  ui->push_close->setEnabled(false); //make sure they cannot close this while it is running 
     25  ui->textEdit->clear(); //make sure this is cleared 
     26  QStringList cmds, dirs, info; //For generating the necessary input to the backend 
    2527  if(cmdtype.toLower() == "ports"){ 
     28    this->setWindowTitle(tr("Getting PC-BSD Ports Tree")); 
    2629    //Check for if the port tree needs to be initialized first 
    2730    qDebug() << "WARNING: Ports init check still needs to be implemented"; 
    2831    bool init = true; 
     32    //Now create the commands necessary 
    2933    if(init){ 
    30       initPorts = true; //set the internal flag 
    3134      ui->textEdit->setPlainText("Starting Ports Tree Initialization...."); 
    32       bool ok = PROC->startInitPorts(); 
    33       if(!ok){  
    34         ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/ports"); 
    35         ui->push_close->setEnabled(true); //they can now close the window 
     35      if(QFile::exists("/usr/ports")){ 
     36        cmds << "rm -rf /usr/ports/* /usr/ports/.g*"; info << "Removing the old ports tree"; dirs << ""; //Clean the old ports tree 
     37      }else{ 
     38        cmds << "mkdir /usr/ports"; info << "Creating the ports tree"; dirs << ""; //Create the ports tree 
    3639      } 
     40      cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/ports"; //setup git 
     41      cmds << "git remote remove origin"; info << ""; dirs <<"/usr/ports"; 
     42      cmds << "git remote add origin https://www.github.com/pcbsd/freebsd-ports.git"; info << ""; dirs << "/usr/ports/.git"; //setup PC-BSD git repo 
    3743    }else{ 
    38       ui->textEdit->setPlainText("Fetching the Ports Tree...."); 
    39       bool ok = PROC->startPorts(); 
    40       if(!ok){  
    41         ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports"); 
    42         ui->push_close->setEnabled(true); //they can now close the window 
    43       } 
     44      ui->textEdit->setPlainText("Updating the Ports Tree...."); 
    4445    } 
     46    //Now create the git update commands 
     47    cmds << "git fetch --depth=1"; info << "Fetch new GIT info (this may take a while)"; dirs << "/usr/ports/.git"; 
     48    cmds << "git checkout master"; info << "Checkout the tree"; dirs << "/usr/ports";  
     49 
    4550  }else if(cmdtype.toLower() == "source"){ 
     51    this->setWindowTitle(tr("Getting PC-BSD Sources")); 
    4652    //Check for if the source tree needs to be initialized first 
    4753    qDebug() << "WARNING: Source init check still needs to be implemented"; 
    4854    bool init = true; 
     55    //Now create the commands necessary 
    4956    if(init){ 
    50       initSource = true; //set the internal flag 
    5157      ui->textEdit->setPlainText("Starting Source Tree Initialization...."); 
    52       bool ok = PROC->startInitSource(); 
    53       if(!ok){  
    54         ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/src"); 
    55         ui->push_close->setEnabled(true); //they can now close the window 
     58      if(QFile::exists("/usr/src")){ 
     59        cmds << "rm -rf /usr/src/* /usr/src/.g*"; info << "Removing the old source tree"; dirs << ""; //Clean the old source tree 
     60      }else{ 
     61        cmds << "mkdir /usr/src"; info << "Creating the source tree"; dirs << ""; //Create the source tree 
    5662      } 
     63      cmds << "git init"; info << "Initialize GIT"; dirs << "/usr/src"; //setup git 
     64      cmds << "git remote remove origin"; info << ""; dirs <<"/usr/src"; 
     65      cmds << "git remote add origin https://www.github.com/pcbsd/freebsd.git"; info << ""; dirs << "/usr/src/.git"; //setup PC-BSD git repo 
    5766    }else{ 
    58       ui->textEdit->setPlainText("Fetching the Source Tree...."); 
    59       bool ok = PROC->startSource(); 
    60       if(!ok){  
    61         ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src"); 
    62         ui->push_close->setEnabled(true); //they can now close the window 
    63       } 
     67      ui->textEdit->setPlainText("Updating the Source Tree...."); 
    6468    } 
     69    //Now create the git update commands 
     70    cmds << "git fetch --depth=1"; info << "Fetch new GIT info (this may take a while)"; dirs << "/usr/src/.git"; 
     71    cmds << "git checkout "+branch; info << "Checkout the right version of the tree"; dirs << "/usr/src";  
    6572  }else{ 
    6673    ui->textEdit->setPlainText("Unknown CMD Type: "+cmdtype); 
    6774    ui->push_close->setEnabled(true); 
     75    ui->push_stop->setEnabled(false); 
     76    return; 
     77  } 
     78  PROC->startCMDs(cmds, dirs, info); 
     79  ui->push_stop->setEnabled(PROC->isRunning()); 
     80} 
     81 
     82bool CMDDialog::isRunning(){ 
     83  return PROC->isRunning(); 
     84} 
     85// ===================== 
     86void CMDDialog::NewMessage(QString msg){ 
     87  if(!msg.isEmpty()){ 
     88    //if(!msg.startsWith("\n")){ msg.prepend("\n"); } //make sure it is on a new line 
     89    ui->textEdit->appendPlainText(msg); //make sure it is on the next line each time     
    6890  } 
    6991} 
    7092 
    71 // ===================== 
    72 void CMDDialog::NewMessage(QString msg){ 
    73   ui->textEdit->appendPlainText("\n"+msg); //make sure it is on the next line each time  
    74 } 
    75  
    76 void CMDDialog::Finished(bool ok){ 
    77   if(!ok){ 
    78     ui->textEdit->appendPlainText("\n=============\nProcess Completed Unsuccessfully"); 
    79     ui->push_close->setEnabled(true); //enabled the close button 
    80   }else if(initPorts){ 
    81     initPorts = false; //make sure it doesn't fall into this catch again 
    82     //ports tree initialized successfully - start the fetch process 
    83     ui->textEdit->appendPlainText("\n=============\nFetching the Ports Tree...."); 
    84     bool ok = PROC->startPorts(); 
    85     if(!ok){  
    86       ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports"); 
    87       ui->push_close->setEnabled(true); //they can now close the window 
    88     } 
    89   }else if(initSource){ 
    90     initSource = false; //make sure it doesn't fall into this catch again 
    91     //Source tree initialized successfully - start the fetch process 
    92     ui->textEdit->appendPlainText("\n=============\nFetching the Source Tree...."); 
    93     bool ok = PROC->startPorts(); 
    94     if(!ok){  
    95       ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src"); 
    96       ui->push_close->setEnabled(true); //they can now close the window 
    97     } 
    98   }else{ 
    99     ui->textEdit->appendPlainText("\n=============\nFinished Successfully"); 
    100   } 
     93void CMDDialog::Finished(){ 
     94    ui->push_close->setEnabled(true); //enable the close button 
     95    ui->push_stop->setEnabled(PROC->isRunning()); 
    10196} 
    10297 
     
    10499  this->close(); 
    105100} 
     101 
     102void CMDDialog::stopProcess(){ 
     103  PROC->stopProc(); 
     104  //PROC should emit the finished signal once done stopping 
     105} 
     106 
     107void CMDDialog::closeEvent(QCloseEvent *event){ 
     108  //Make sure the user does not close this window while a process is running 
     109  event->ignore(); 
     110  if(!ui->push_close->isEnabled()){ 
     111    QMessageBox::warning(this, tr("Process Running"), tr("Please stop the current process before closing this window.") ); 
     112  }else{ 
     113    //Make sure this window is only hidden (pbsystemtab needs to make sure it always exists for checks); 
     114    this->hide(); 
     115  } 
     116} 
  • src-qt4/pc-sysmanager/cmdDialog.h

    r6d7b1e6 r8a4c7a0  
    55#include <QString> 
    66#include <QWidget> 
     7#include <QMessageBox> 
    78 
    8 #include "gitprogress.h" 
     9#include "longProc.h" 
    910 
    1011namespace Ui{ 
     
    1819        ~CMDDialog(); 
    1920 
    20         void start(QString cmdtype); 
     21        void start(QString cmdtype, QString branch = ""); 
     22        bool isRunning(); 
    2123 
    2224private: 
    2325        Ui::CMDDialog *ui; 
    24         gitProc *PROC; 
    25         bool initPorts, initSource; //to keep track if only the first step was running 
     26        LongProc *PROC; 
    2627 
    2728private slots: 
    2829        void NewMessage(QString); 
    29         void Finished(bool); 
     30        void Finished(); 
    3031        void CloseUI(); 
     32        void stopProcess(); 
     33 
     34protected: 
     35        void closeEvent(QCloseEvent *event); 
    3136}; 
    3237#endif 
  • src-qt4/pc-sysmanager/cmdDialog.ui

    r6d7b1e6 r8f95077  
    1616  <layout class="QVBoxLayout" name="verticalLayout"> 
    1717   <item> 
    18     <widget class="QPlainTextEdit" name="textEdit"/> 
     18    <widget class="QPlainTextEdit" name="textEdit"> 
     19     <property name="readOnly"> 
     20      <bool>true</bool> 
     21     </property> 
     22    </widget> 
    1923   </item> 
    2024   <item> 
    2125    <layout class="QHBoxLayout" name="horizontalLayout"> 
     26     <item> 
     27      <widget class="QPushButton" name="push_stop"> 
     28       <property name="text"> 
     29        <string>Stop</string> 
     30       </property> 
     31      </widget> 
     32     </item> 
    2233     <item> 
    2334      <spacer name="horizontalSpacer"> 
     
    4455  </layout> 
    4556 </widget> 
    46  <resources/> 
     57 <resources> 
     58  <include location="PBSystem.qrc"/> 
     59 </resources> 
    4760 <connections/> 
    4861</ui> 
  • src-qt4/pc-sysmanager/longProc.h

    r6d7b1e6 r8f95077  
    1 #ifndef _GIT_PROGRESS_H 
    2 #define _GIT_PROGRESS_H 
     1#ifndef _LONG_PROGRESS_H 
     2#define _LONG_PROGRESS_H 
    33 
    44#include <QObject> 
     
    99#include <QCoreApplication> 
    1010#include <QDebug> 
     11#include <QTimer> 
    1112 
    12 class gitProc : public QObject{ 
     13class LongProc : public QObject{ 
    1314        Q_OBJECT 
    1415public: 
    1516         
    16         gitProc(); 
    17         ~gitProc(); 
     17        LongProc(); 
     18        ~LongProc(); 
    1819         
    1920        //Quick-start functions for specific tasks 
    20         bool startInitPorts(); //initialize the ports tree 
    21         bool startPorts(); //fetch the ports tree 
    22         bool startInitSource(); //initialize the source fetching 
    23         bool startSource(); //fetch the source tree 
     21        bool startCMDs(QStringList cmds, QStringList dirs, QStringList info); 
     22        void stopProc(); 
    2423 
    2524        //Information functions 
     
    3130private: 
    3231        QProcess *process; 
    33         bool running; 
    34         gitProc *longProcess; 
     32        bool running, stopped; 
     33        QStringList cmdList, infoList, dirList; 
     34        int currentItem; 
     35        QTimer *timer; 
    3536 
    3637private slots: 
    3738        void parseUpdate(); //New process message from internal worker 
    3839        void procDone(); //internal worker finished 
     40        void procTimeout(); //internal timeout signal 
    3941 
    4042signals: 
    4143        void ProcMessage(QString); //a new message while it is running 
    42         void ProcFinished(bool); //the process result (good/bad) 
     44        void ProcFinished(); 
    4345}; 
    4446#endif 
  • src-qt4/pc-sysmanager/pbsystemtab.cpp

    r7cd7e8f r8a4c7a0  
    2626{ 
    2727    //Grab the username 
    28     username = QString::fromLocal8Bit(getenv("SUDO_USER")); 
    29     qDebug() << "Username:" << username; 
     28    username = QString::fromLocal8Bit(getenv("SUDO_USER")); //since the app is always run as root with sudo 
     29    if(username.isEmpty()){ username = QString::fromLocal8Bit(getenv("LOGNAME")); } //in case SUDO_USER is not set 
     30    //qDebug() << "Username:" << username; 
    3031    // Set the Uname on the General Tab 
    3132    CheckUname(); 
     
    6869    connect(fetchSourceBut, SIGNAL( clicked() ), this, SLOT( fetchSourcePressed() ) ); 
    6970    connect(fetchPortsBut, SIGNAL( clicked() ), this, SLOT( fetchPortsPressed() ) ); 
     71     
     72    cmdDlg = new CMDDialog(this); 
     73    cmdDlg->hide(); 
    7074} 
    7175 
     
    148152        args << SheetFileName; 
    149153        args << username; 
    150         qDebug() << "CMD: " << prog+" "+args.join(" "); 
     154        //qDebug() << "CMD: " << prog+" "+args.join(" "); 
    151155        connect( SheetGenScript, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finishedSheet()) ); 
    152156                 
     
    206210void PBSystemTab::fetchSourcePressed() 
    207211{ 
    208     portsnapUI = new CMDDialog(this); 
    209     portsnapUI->start("source"); //Version not implemented yet 
    210     portsnapUI->show(); 
     212    if(cmdDlg->isRunning() ){ 
     213      QMessageBox::warning(this, tr("Process Already Running"), tr("You already have a process running. Please wait for that one to finish first.") ); 
     214    }else{ 
     215      //Get the current version branch of the source tree 
     216      QString version = pcbsd::Utils::runShellCommand("uname -r").join(" "); 
     217      QString branch; 
     218      if(version.contains("RELEASE")){ branch = "releng/"+version.section("-",0,0).simplified(); } 
     219      else if(version.contains("STABLE")){ branch = "stable/"+version.section("-",0,0).section(".",0,0).simplified(); } 
     220      else{ branch = "master"; } //CURRENT 
     221       
     222      cmdDlg->start("source", branch); //Version not implemented yet 
     223      cmdDlg->show(); 
     224    } 
    211225} 
    212226 
    213227void PBSystemTab::fetchPortsPressed() 
    214228{ 
    215     portsnapUI = new CMDDialog(this); 
    216     portsnapUI->start("ports"); //Version not implemented yet 
    217     portsnapUI->show(); 
     229    if(cmdDlg->isRunning() ){ 
     230      QMessageBox::warning(this, tr("Process Already Running"), tr("You already have a process running. Please wait for that one to finish first.") ); 
     231    }else{ 
     232      cmdDlg->start("ports"); //Version not implemented yet 
     233      cmdDlg->show(); 
     234    } 
    218235} 
    219236 
     
    371388  QNetworkProxy::setApplicationProxy(proxy); 
    372389} 
     390 
     391void PBSystemTab::closeEvent(QCloseEvent *event){ 
     392    if(cmdDlg->isRunning()){ 
     393      //Process Running - minimize the main window instead 
     394      event->ignore(); 
     395      this->showMinimized(); 
     396    } 
     397} 
  • src-qt4/pc-sysmanager/pbsystemtab.h

    r7cd7e8f r8f95077  
    1212#include <QTextStream> 
    1313#include <QTimer> 
     14#include <QCloseEvent> 
    1415 
    1516#include <pcbsd-utils.h> 
     
    7576    QProcess *GetPBVer; 
    7677    QProcess *GetUname; 
    77     CMDDialog *portsnapUI; 
     78    CMDDialog *cmdDlg; 
    7879    QString username; 
    7980    bool miscChanged; 
     
    140141    metaWidget *pkgWidget; 
    141142 
     143protected: 
     144        void closeEvent(QCloseEvent *event); 
    142145 
    143146signals: 
  • src-qt4/pc-sysmanager/pbsystemtab.ui

    rba438ce ra4325b4  
    660660  <include location="local">qfile.h</include> 
    661661  <include location="local">qsettings.h</include> 
    662   <include location="local">gitprogress.h</include> 
    663662  <include location="global">qregexp.h</include> 
    664663  <include location="global">pcbsd-utils.h</include> 
  • src-qt4/pc-sysmanager/pc-sysmanager.pro

    ra2d9be06 ra4325b4  
    99 
    1010HEADERS += pbsystemtab.h \ 
    11         gitprogress.h \ 
    1211        updaterDialog.h \ 
    13         cmdDialog.h 
     12        cmdDialog.h \ 
     13        longProc.h 
    1414 
    1515SOURCES += main.cpp \ 
    1616        pbsystemtab.cpp \ 
    17         gitprogress.cpp \ 
    1817        updaterDialog.cpp \ 
    19         cmdDialog.cpp 
     18        cmdDialog.cpp \ 
     19        longProc.cpp 
     20         
    2021 
    2122FORMS   = pbsystemtab.ui \ 
    22         gitprogress.ui \ 
    2323        updaterDialog.ui \ 
    2424        cmdDialog.ui 
  • src-sh/pbi-manager/install.sh

    r8188062 ra7429d5  
    139139install -o root -g wheel -m 755 pbimount ${LB}/share/pbi-manager/.pbimount 
    140140install -o root -g wheel -m 755 ldconfig ${LB}/share/pbi-manager/.ldconfig 
     141install -o root -g wheel -m 755 pbisyslisten ${LB}/share/pbi-manager/.pbisyslisten 
     142install -o root -g wheel -m 755 pbisyscmd ${LB}/share/pbi-manager/.pbisyscmd 
    141143if [ "${LB}" = "/usr/local" ] ; then 
    142144  install -o root -g wheel -m 4751 pbime /usr/pbi/.pbime 
    143145  install -o root -g wheel -m 755 pbimount /usr/pbi/.pbimount 
    144146  install -o root -g wheel -m 755 ldconfig /usr/pbi/.ldconfig 
     147  install -o root -g wheel -m 755 pbisyslisten /usr/pbi/.pbisyslisten 
     148  install -o root -g wheel -m 755 pbisyscmd /usr/pbi/.pbisyscmd 
    145149fi 
    146150 
  • src-sh/pbi-manager/pbime/Makefile

    r7ff5d68 ra7429d5  
    99        install -o root -g wheel -m 755 pbimount /usr/pbi/.pbimount 
    1010        install -o root -g wheel -m 755 ldconfig /usr/pbi/.ldconfig 
     11        install -o root -g wheel -m 755 pbisyslisten /usr/pbi/.pbisyslisten 
     12        install -o root -g wheel -m 755 pbisyscmd /usr/pbi/.pbisyscmd 
  • src-sh/pbi-manager/pbime/pbime.c

    rb3e939a ra7429d5  
    22 * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> 
    33 * Copyright (c) 2007 Bill Moran/Collaborative Fusion 
    4  * Copyright (c) 2013 Kris Moore/PC-BSD Software <kris@pcbsd.org> 
     4 * Copyright (c) 2014 Kris Moore/PC-BSD Software <kris@pcbsd.org> 
    55 * All rights reserved. 
    66 * 
     
    3131#include <sys/jail.h> 
    3232#include <sys/types.h> 
     33#include <sys/wait.h> 
    3334 
    3435#include <err.h> 
     
    4344static void     usage(void); 
    4445 
    45 int 
    46 main(int argc, char *argv[]) 
     46void ch_user(void); 
     47 
     48void ch_user(void) 
    4749{ 
    48         char newchroot[2048]; 
    49         char mountscript[4096]; 
    5050        int jid, ngroups; 
    51         int argoffset; 
    5251        uid_t huid; 
    5352        struct passwd *husername, *jusername; 
     
    5554        login_cap_t *lcap; 
    5655 
    57         /* Is this a request to unmount? */ 
    58         if ( argc == 3 ) { 
    59                 if ( strcmp(argv[1], "umount") == 0 ) { 
    60                         strcpy(mountscript, "/usr/pbi/.pbimount umount "); 
    61                         strcat(mountscript, argv[2]); 
    62                         return system(mountscript); 
    63                 } 
    64         } 
    65  
    66         if (argc < 4) 
    67                 usage(); 
    68  
    6956        /* Get the current user ID and user name in the host system */ 
    7057        huid = getuid(); 
    7158        husername = getpwuid(huid); 
    72  
    73         /* Run the mount script */ 
    74         if ( (strlen("/usr/pbi/.pbimount") + strlen(argv[1]) + strlen(argv[2])) > 4090) 
    75                 err(1, "Max length exceeded for pbidir / mntdir"); 
    76  
    77         if ( strlen("argv[2]") + strlen("/virtbase") > 2040) 
    78                 err(1, "Max length exceeded for virtbase"); 
    79         strcpy(newchroot, argv[1]); 
    80         strcat(newchroot, "/virtbase"); 
    81          
    82         strcpy(mountscript, "/usr/pbi/.pbimount "); 
    83         strcat(mountscript, argv[1]); 
    84         strcat(mountscript, " "); 
    85         strcat(mountscript, argv[2]); 
    86         //printf( "mountscript: %s \n", mountscript); 
    87         if ( system(mountscript) != 0 ) 
    88                 err(1, "Failed mounting PBI"); 
    89  
    90         if (chdir(newchroot) == -1 || chroot(".") == -1) 
    91                 err(1, "Could not chroot to: %s", newchroot); 
    92  
    93         argoffset=4; 
    94         if (chdir(argv[4]) == -1 ) { 
    95                 // Running with old pbi wrapper 
    96                 argoffset=3; 
    97         } 
    9859 
    9960        /* Get the user name in the jail */ 
     
    10162        if (jusername == NULL || strcmp(husername->pw_name, jusername->pw_name) != 0) 
    10263                err(1, "Username mapping failed"); 
    103         //if (chdir("/") == -1) 
    104         //      err(1, "chdir(): /"); 
    10564        lcap = login_getpwclass(jusername); 
    10665        if (lcap == NULL) { 
     
    11877                err(1, "setusercontext"); 
    11978        login_close(lcap); 
    120         if (execvp(argv[3], argv + argoffset) == -1) 
    121                 err(1, "execvp(): %s", argv[3]); 
     79} 
     80 
     81int 
     82main(int argc, char *argv[]) 
     83{ 
     84        char newchroot[2048]; 
     85        char mountscript[4096]; 
     86        char pipetemplate[] = "/tmp/.pbi-callback-XXXXXXXXXXXXXXXX"; 
     87        char *pipedir; 
     88        char fifoin[MAXPATHLEN];  
     89        int argoffset; 
     90 
     91        pid_t listen_pid; 
     92        pid_t app_pid; 
     93        int listen_status; 
     94        int app_status; 
     95 
     96        /* Is this a request to unmount? */ 
     97        if ( argc == 3 ) { 
     98                if ( strcmp(argv[1], "umount") == 0 ) { 
     99                        strcpy(mountscript, "/usr/pbi/.pbimount umount "); 
     100                        strcat(mountscript, argv[2]); 
     101                        return system(mountscript); 
     102                } 
     103        } 
     104 
     105        if (argc < 4) 
     106                usage(); 
     107 
     108 
     109        /* Run the mount script */ 
     110        if ( (strlen("/usr/pbi/.pbimount") + strlen(argv[1]) + strlen(argv[2])) > 4090) 
     111                err(1, "Max length exceeded for pbidir / mntdir"); 
     112 
     113        if ( strlen("argv[2]") + strlen("/virtbase") > 2040) 
     114                err(1, "Max length exceeded for virtbase"); 
     115        strcpy(newchroot, argv[1]); 
     116        strcat(newchroot, "/virtbase"); 
     117         
     118        strcpy(mountscript, "/usr/pbi/.pbimount "); 
     119        strcat(mountscript, argv[1]); 
     120        strcat(mountscript, " "); 
     121        strcat(mountscript, argv[2]); 
     122        //printf( "mountscript: %s \n", mountscript); 
     123        if ( system(mountscript) != 0 ) 
     124                err(1, "Failed mounting PBI"); 
     125 
     126        // Lets get our template directory 
     127        pipedir = mktemp(pipetemplate); 
     128 
     129        // Set the environment variable 
     130        setenv("PBI_SYSPIPE", pipedir, 1); 
     131         
     132        // Fork off a listener for system commands 
     133        listen_pid = fork(); 
     134        if(listen_pid == 0) { 
     135                /* This is done by the child process. */ 
     136                // drop priv 
     137                ch_user(); 
     138 
     139                // Create the pipe file 
     140                strcpy(fifoin, "mkfifo "); 
     141                strcat(fifoin, pipedir); 
     142                if ( system(fifoin) == 0 ) { 
     143                        // Start the listen process only if mkfifo is successful 
     144                        exit(system("sh /usr/pbi/.pbisyslisten")); 
     145                } 
     146        } else { 
     147 
     148                // Do the chroot 
     149                if (chdir(newchroot) == -1 || chroot(".") == -1) 
     150                        err(1, "Could not chroot to: %s", newchroot); 
     151 
     152                // drop priv 
     153                ch_user(); 
     154 
     155                // Backwards compat check for old PBIs 
     156                argoffset=4; 
     157                if (chdir(argv[4]) == -1 ) { 
     158                        // Running with old pbi wrapper 
     159                        argoffset=3; 
     160                } 
     161 
     162 
     163                // Fork off the PBI process, and have the parent wait for it to finish 
     164                app_pid = fork(); 
     165                if(app_pid == 0) { 
     166                        // Execute the PBI now 
     167                        if (execvp(argv[3], argv + argoffset) == -1) 
     168                                err(1, "execvp(): %s", argv[3]); 
     169                        exit(0); 
     170                } else { 
     171                        /* This is run by the parent.  Wait for the child to terminate. */ 
     172                        pid_t tpid; 
     173                        do { 
     174                                tpid = wait(&app_status); 
     175                        } while(tpid != app_pid); 
     176 
     177                        // Stop the listener 
     178                        strcpy(fifoin, "echo 'CLOSE:' > "); 
     179                        strcat(fifoin, pipedir); 
     180                        system(fifoin); 
     181 
     182                        // Remove the old pipefile 
     183                        strcpy(fifoin, "rm "); 
     184                        strcat(fifoin, pipedir); 
     185                        system(fifoin); 
     186 
     187                        return app_status; 
     188                } 
     189 
     190        } 
     191 
    122192        exit(0); 
    123193} 
     
    127197{ 
    128198 
    129         fprintf(stderr, "usage: pbime mntdir pbidir command [...]\n"); 
     199        fprintf(stderr, "usage: pbime mntdir pbidir command cwd [...]\n"); 
    130200        exit(1);  
    131201} 
  • src-sh/pbi-manager/pbime/pbimount

    rf1dc8cf ra7429d5  
    7272 
    7373   sync 
     74 
     75   # Copy over the system command 
     76   cp /usr/pbi/.pbisyscmd "${pDir}/virtbase/usr/local/bin/pbisyscmd" 
     77   cp /usr/pbi/.pbisyscmd "${pDir}/virtbase/usr/local/bin/openwith" 
     78   cp /usr/pbi/.pbisyscmd "${pDir}/virtbase/usr/local/bin/xdg-open" 
     79   chmod 755 "${pDir}/virtbase/usr/local/bin/pbisyscmd"  
     80 
     81   # Copy the custom ldconfig 
    7482   cp /usr/pbi/.ldconfig "${pDir}/virtbase/var/run/ldconfig" 
    7583   chroot "${pDir}/virtbase" /var/run/ldconfig start >/dev/null 2>/dev/null 
  • src-sh/port-files/pkg-install

    r9b2c4e1 ra7429d5  
    3333   install -o root -g wheel -m 755 ${PREFIX}/share/pbi-manager/.pbimount /usr/pbi/.pbimount 
    3434   install -o root -g wheel -m 755 ${PREFIX}/share/pbi-manager/.ldconfig /usr/pbi/.ldconfig 
     35   install -o root -g wheel -m 755 ${PREFIX}/share/pbi-manager/.pbisyscmd /usr/pbi/.pbisyscmd 
     36   install -o root -g wheel -m 755 ${PREFIX}/share/pbi-manager/.pbisyslisten /usr/pbi/.pbisyslisten 
    3537   install -o root -g wheel -m 755 ${PREFIX}/share/pbi-manager/.mount_nullfs /usr/pbi/.mount_nullfs 
    3638fi 
  • src-sh/port-files/pkg-plist

    rd2b761b ra7429d5  
    589589share/pbi-manager/.pbime 
    590590share/pbi-manager/.pbimount 
     591share/pbi-manager/.pbisyscmd 
     592share/pbi-manager/.pbisyslisten 
    591593share/pbi-manager/.ldconfig 
    592594share/pbi-manager/.mount_nullfs 
Note: See TracChangeset for help on using the changeset viewer.