Anywho, I have an embedded Linux system running OE-Yocto project Rocko-2.4.2, with the ftpd package built into Busybox-1.24.1. I have used Busybox's menuconfig to enable the FTP feature (ftpd, Enable upload commands, Enable workaround for RFC-violating clients (though I'm not entirely sure what this does...), Enable authentication.)
The ftp server is launched on startup from a systemd service script as follows:
Code: Select all
ExecStart=/usr/bin/tcpsvd -vE 0.0.0.0 21 /usr/sbin/ftpd -wS /home/root
Code: Select all
/var/log /home/root/var/log none bind 0 0
When I try using wxFTP to fetch the logs programmatically, for what ever reason, the wxFTP client doesn't seem to have permissions? I get the ftp error 550, which could be a few things but based on the behavior I observe I guessing permissions. wxFTP code looks like this:
Code: Select all
void CouchView::OnRetrieveCouchLogs(wxCommandEvent& event)
{
// Prompt the user for a file name
wxFileDialog saveFileDialog(this, wxEmptyString, wxEmptyString,
"CouchLogs.zip", "Supported Files (*.zip)|*.zip", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (saveFileDialog.ShowModal() == wxID_OK)
{
wxString FileName = saveFileDialog.GetFilename();
wxString FullPath = saveFileDialog.GetPath();
wxString FolderPath = FullPath.BeforeLast(wxFileName::GetPathSeparator());
// Create a progress dialog for retrieval
wxProgressDialog progressDialog(wxTheApp->GetAppName(),
"Retrieving logs. Please wait...", 0, wxTheApp->GetTopWindow(), wxPD_APP_MODAL);
// connect to FTP server
wxFTP ftp;
ftp.SetUser("root");
ftp.SetPassword("password");
ftp.SetDefaultTimeout(3);
if ( !ftp.Connect("192.168.10.7") )
{
wxMessageBox("Failed to connect to FTP server to retrieve files.",
"Retrieval Error", wxOK | wxICON_EXCLAMATION);
return;
}
ftp.SetBinary();
ftp.ChDir("/home/root/var/log/");
ftp.GetFilesList(files);
if(files.size() <= 0)
{
return;
}
// create zip archive
wxFFileOutputStream out(FullPath);
if(!out.IsOk())
{
wxMessageBox("wxFFileOutputStream is not valid",
"Retrieval Error", wxOK | wxICON_EXCLAMATION);
return;
}
wxZipOutputStream zip(out, -1, wxConvUTF8);
if(!zip.IsOk())
{
wxMessageBox("wxZipOutputStream is not valid",
"Retrieval Error", wxOK | wxICON_EXCLAMATION);
return;
}
// retrieve each file and store it in the zip archive
for (size_t i = 0; i < files.size(); i++)
{
wxInputStream* in = ftp.GetInputStream(files[i]);
// make sure we've got good data
if (in)
{
// Write the downloaded file to the zip archive
if(zip.PutNextEntry(files[i]))
{
zip.Write(*in);
wxString msg = wxString::Format( wxT(" bytes written = '%d' "), zip.LastWrite() );
wxMessageBox(msg.mb_str(), "Attempting write", wxOK | wxICON_EXCLAMATION);
msg = wxString::Format( wxT(" Last Error = '%d' "), zip.GetLastError() );
wxMessageBox(msg.mb_str(), "DEBUG ", wxOK | wxICON_EXCLAMATION);
}
else
{
wxMessageBox("Failed to add file to zip",
"Retrieval Error", wxOK | wxICON_EXCLAMATION);
return;
}
// delete the file download stream
delete in;
}
else
{
wxMessageBox("Failed to get wxInputStream",
"Retrieval Error", wxOK | wxICON_EXCLAMATION);
return;
}
}
}
}
Any ideas?