Samba Audit no filename appear - samba

I'm using samba to provide shares to users. The sometimes claim their files have mysteriously disappeared so I am keen to track deletions.
Thus I set up full audit. Everything works, except the audit log is often missing the file name or has some sort of mystery code. For example;
Dec 12 17:46:04 server1 smbd_audit:
shared|shared|192.168.x.x|matt1|shared|2016/12/12
17:46:04|server1|file_id_create|ok|802:28200da:0
The last item should presumably be a file name. Why is there a number instead?
The relevant parts of smb.conf follows
[homes]
comment = Home Directories directory mask = 0775
browseable = yes
read only = no
create mask = 0775
directory mask = 0775
valid users = %S
writable = yes
vfs objects = recycle
recycle:repository = .RecycleBin
recycle:keeptree = yes
recycle:exclude = *.tmp, *.bak
vfs objects = full_audit
full_audit:prefix = %u|%U|%I|%m|%S|%T|%D
full_audit:success = mkdir rename unlink rmdir open
full_audit:failure = none
full_audit:facility = LOCAL5
full_audit:priority = NOTICE

Related

Change the items of JComboBox depending on File Chosen

I am using Jython to create a GUI. I include a button - Upload which when clicked opens up a FileChooser and depending on the File chosen, I want to create my JComboBox. When the file is changed/ another file is uploaded, the items of JComboBox should also change.
def upload(self,event):
self.chooseFile = JFileChooser()
filter = FileNameExtensionFilter("c files", ["c"])
self.chooseFile.addChoosableFileFilter(filter)
ret = self.chooseFile.showDialog(frame_2, "Choose file")
if ret == JFileChooser.APPROVE_OPTION:
file_name = self.chooseFile.getSelectedFile().getName()
txt4.setText(file_name)
file = self.chooseFile.getSelectedFile()
global file_path
file_path = file.getCanonicalPath()
with open(file_path) as f:
first_line = f.readline()
self.list_columns = first_line.split("\t")
self.source = JComboBox(self.list_columns)
self.target = JComboBox(self.list_columns)
self.source.setBounds(200,240,200,100)
self.target.setBounds(600,240,200,100)
When the above code is made to run, the dropdown for JComboBox does not change, instead, it remains of the previous file. Can anybody help me on how to clear and update the items of JComboBox?

How to get corresponding file in another folder in Octave/MATLAB?

In one of my folders (say Folder01) there are files like "IGN_A.txt", "IGN_B.txt", "IGN_C.txt".........
In another folder (say Folder02) there are files like "sim_IGN_A_M01.txt", "sim_IGN_A_M02.txt", "sim_IGN_A_M03.txt" for the corresponding file "IGN_A.txt" in Folder01.
Similarly, "sim_IGN_B_M01.txt", "sim_IGN_B_M02.txt", "sim_IGN_B_M03.txt" for corresponding file "IGN_B.txt" in Folder01.
How can I get the corresponding files from those Folders.
For example, I want to get "IGN_A.txt" along with "sim_IGN_A_M01.txt", "sim_IGN_A_M02.txt", "sim_IGN_A_M03.txt".
Here. I added my code which can only get "IGN_A.txt" along with "sim_IGN_A.txt".
Folder01 = 'Home/A1';
Folder02 = 'Home/A2';
%Going Throuh all the Folder01 files
Allfiles_Folder01 = dir(fullfile(Folder01, '*IGN*.txt'));
for k = 1:length(Allfiles_Folder01)
fullFileName = fullfile(Folder01, Allfiles_Folder01(k).name);
READ_Folder01=dlmread(fullFileName,'',2,0);
fullFileName_Sim = fullfile(Folder02, strcat('sim_',Allfiles_Folder01(k).name))
READ_Folder02=dlmread(fullFileName_Sim,'',1,0);
end
If the naming convention is consistent as provided by you, this would be my suggestion:
% Get all filenames from Folder01 in cell array.
Allfiles_Folder01 = dir(fullfile(Folder01, '*IGN*.txt'));
Allfiles_Folder01 = {Allfiles_Folder01.name}
% Iterate all filenames from Folder01.
for k = 1:numel(Allfiles_Folder01)
% Cut file extension from current filename.
filename = Allfiles_Folder01{k};
filename = filename(1:end-4);
% Get all filenames from Folder02 with specific search string in cell array.
Allfiles_Folder02 = dir(fullfile(Folder02, strcat('*', filename, '*.txt')));
Allfiles_Folder02 = {Allfiles_Folder02.name}
% Do stuff with filenames from Folder02 corresponding to filename from Folder01.
% ...
% ...
end

Search files recursively using google drive rest

I am trying to grab all the files created under a parent directory. The parent directory has a lot of sub directories followed by files in those directories.
parent
--- sub folder1
--- file1
--- file2
Currently I am grabbing all the ids of sub folders and constructing a query such as q: 'subfolder1id' in parents or 'subfolder2id' in parents to find the list of files. Then I issue these in batches. If I have 100 folders, I issue 10 search queries for a batch size of 10.
Is there a better way of querying the files using google drive rest api that will get me all the files with one query?
Here is an answer to your question.
Same idea from your scenario:
folderA____ folderA1____folderA1a
\____folderA2____folderA2a
\___folderA2b
There 3 alternative answers that I think you can get an idea from.
Alternative 1. Recursion
The temptation would be to list the children of folderA, for any
children that are folders, recursively list their children, rinse,
repeat. In a very small number of cases, this might be the best
approach, but for most, it has the following problems:-
It is woefully time consuming to do a server round trip for each sub folder. This does of course depend on the size of your tree, so if
you can guarantee that your tree size is small, it could be OK.
Alternative 2. The common parent
This works best if all of the files are being created by your app (ie.
you are using drive.file scope). As well as the folder hierarchy
above, create a dummy parent folder called say "MyAppCommonParent". As
you create each file as a child of its particular Folder, you also
make it a child of MyAppCommonParent. This becomes a lot more
intuitive if you remember to think of Folders as labels. You can now
easily retrieve all descdendants by simply querying MyAppCommonParent
in parents.
Alternative 3. Folders first
Start by getting all folders. Yep, all of them. Once you have them all
in memory, you can crawl through their parents properties and build
your tree structure and list of Folder IDs. You can then do a single
files.list?q='folderA' in parents or 'folderA1' in parents or
'folderA1a' in parents.... Using this technique you can get
everything in two http calls.
Alternative 2 is the most effificient, but only works if you have
control of file creation. Alternative 3 is generally more efficient
than Alternative 1, but there may be certain small tree sizes where 1
is best.
scope = ['https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('your JSON credentials' % path, scope)
service = build('drive', 'v3', credentials=credentials)
folder_tree = "NAME OF THE FOLDER YOU WANT TO START YOUR SEARCH"
folder_ids = {}
folder_ids['NAME OF THE FOLDER YOU WANT TO START YOUR SEARCH'] = folder_id
def check_for_subfolders(folder_id):
new_sub_patterns = {}
folders = service.files().list(q="mimeType='application/vnd.google-apps.folder' and parents in '"+folder_id+"' and trashed = false",fields="nextPageToken, files(id, name)",pageSize=400).execute()
all_folders = folders.get('files', [])
all_files = check_for_files(folder_id)
n_files = len(all_files)
n_folders = len(all_folders)
old_folder_tree = folder_tree
if n_folders != 0:
for i,folder in enumerate(all_folders):
folder_name = folder['name']
subfolder_pattern = old_folder_tree + '/'+ folder_name
new_pattern = subfolder_pattern
new_sub_patterns[subfolder_pattern] = folder['id']
print('New Pattern:', new_pattern)
all_files = check_for_files(folder['id'])
n_files =len(all_files)
new_folder_tree = new_pattern
if n_files != 0:
for file in all_files:
file_name = file['name']
new_file_tree_pattern = subfolder_pattern + "/" + file_name
new_sub_patterns[new_file_tree_pattern] = file['id']
print("Files added :", file_name)
else:
print('No Files Found')
else:
all_files = check_for_files(folder_id)
n_files = len(all_files)
if n_files != 0:
for file in all_files:
file_name = file['name']
subfolders[folder_tree + '/'+file_name] = file['id']
new_file_tree_pattern = subfolder_pattern + "/" + file_name
new_sub_patterns[new_file_tree_pattern] = file['id']
print("Files added :", file_name)
return new_sub_patterns
def check_for_files(folder_id):
other_files = service.files().list(q="mimeType!='application/vnd.google-apps.folder' and parents in '"+folder_id+"' and trashed = false",fields="nextPageToken, files(id, name)",pageSize=400).execute()
all_other_files = other_files.get('files', [])
return all_other_files
def get_folder_tree(folder_id):
global folder_tree
sub_folders = check_for_subfolders(folder_id)
for i,sub_folder_id in enumerate(sub_folders.values()):
folder_tree = list(sub_folders.keys() )[i]
print('Current Folder Tree : ', folder_tree)
folder_ids.update(sub_folders)
print('****************************************Recursive Search Begins**********************************************')
try:
get_folder_tree(sub_folder_id)
except:
print('---------------------------------No furtherance----------------------------------------------')
return folder_ids
folder_ids = get_folder_tree(folder_id)

How to go about creating XLS file (Matlab/HTML/JS)?

I have been using MATLAB to ask plenty of questions via questdlg and then saving all the answers as data = {'Name of variable1', 'Name of variable2', etc}. I am on a MAC so xlswrite does not work. I have used xlwrite and it works when I hit run in MATLAB. I have compiled this via the Application compiler and included the xlwrite file. When running the file, the questions are asked, but the file is not created. This is a little odd as it works and creates the file in MATLAB directly.
I switched to dlmcell and this works in MATLAB but not when run externally. As this needs to run on Windows and MAC I would have to use dlmcell? (testing on mac, then distributing on mac and windows).
What I am trying to find out, is why would it work in MATLAB but not when compiled? If this is a big problem, then I thought HTML would be a good choice. Can I write data to .txt/.xls via HTML?
prompt = {'Enter serial number'};
dlg_title = 'Serial Number';
num_lines = 1;
defaultans = {'15'};
Serial_Number = inputdlg(prompt,dlg_title,num_lines,defaultans);
SN = char(Serial_Number) %ANSWER%
prompt = {'Enter your name'};
dlg_title = 'Your name';
num_lines = 1;
defaultans = {''};
Name = inputdlg(prompt,dlg_title,num_lines,defaultans);
User = char(Name) %ANSWER%
%%PREPERATION%%
LicensePI = 'Which license is installed?'; %QUESTION%
set(0,'DefaultImageVisible','off') %Disables icon
LicensePIAns = questdlg('Which license is installed?', 'Preperation', 'Basic', 'Medium','Advanced'); %ANSWER%
LicenseGen = 'Which type of temporary license was preferred?'; %QUESTION%
LicensGenAns = questdlg('Which type of temporary license was preferred?', 'Basic', 'Medium', 'Advanced'); %ANSWER%
%%PREPERATION%%
filename = 'Test.xls';
data = {SN, User, LicensePI, LicensePIAns, LicenseGen, LicensGenAns}
dlmcell('sat.txt',data);

Corona SDK JSON usage

I have an operating JSON library which I use to load an array of tile IDs. When I double click main.lua directly from file explorer, it runs great, but when I open Corona Simulator and open my project from there or build my project and run it on my testing device, it gives me a null reference error when I attempt to use the data I loaded.
Here is the function to load a table from a JSON file:
function fileIO.loadJSONFile (fileName)
local path = fileName
local contents = ""
local loadingTable = {}
local file = io.open (path, "r")
print (file)
if file then
local contents = file:read ("*a")
loadingTable = json.decode (contents)
io.close (file)
return loadingTable
end
return nil
end
Here is the usage:
function wr:renderChunkFile (path)
local data = fileIO.loadJSONFile (path)
self:renderChunk (data)
end
function wr:renderChunk (data)
local a, b = 1
if (self.img ~= nil) then
a = #self.img + 1
self.img[a] = {}
else
self.img[1] = {}
end
if (self.chunks ~= nil) then
b = #self.chunks + 1
self.chunks[b] = display.newGroup ()
else
self.chunks[1] = display.newGroup ()
end
for i = 1, #data do -- Y axis ERROR IS HERE
self.img[a][i] = {}
for j = 1, #data[i] do -- Z axis
self.img[a][i][j] = {}
for k = 1, #data[i][j] do -- X axis
if (data[i + 1] ~= nil) then
if (data[i + 1][j][k] < self.transparentLimit) then
self.img[a][i][j][k] = display.newImage ("images/tiles/"..data[i][j][k]..".png", k*self.tileWidth, display.contentHeight -j*self.tileDepth - i*self.tileThickness)
self.chunks[b]:insert (self.img[a][i][j][k])
elseif(data[i + 1] == nil) then
self.img[a][i][j][k] = display.newImage ("images/tiles/"..data[i][j][k]..".png", k*self.tileWidth, display.contentHeight -j*self.tileDepth - i*self.tileThickness)
self.chunks[b]:insert (self.img[a][i][j][k])
end
end
end
end
end
end
When it gets to the line for i = 1, #data do it tells me it is trying to access the length of a nil field. Where did I go wrong here?
EDIT: I feel the need to give a more clear explanation of what my problem is. I am getting inconsistent results from this program. When I select main.lua in file explorer and open it with Corona Simulator, it works. When I open Corona Simulator and internally navigate to main.lua, it does not work. When I build the project and test it on my device, it does not work. What I really need is some insight into Corona's JSON library and APK internal directory structure requirements (directory nesting limits, naming restrictions, etc.). If someone thinks of something else that might cause the issue I am having, please bring it up! I am open to anything.
Without seeing the entire error message and not knowing what the value of "path" is it's going to be hard to speculate. But Corona SDK uses four base directories:
system.ResourceDirectory -- Same folder as main.lua and is read-only
system.DocumentsDirectory -- Your writable folder where your data lives
system.CachesDirectory -- for downloaded files
system.TemporaryDirectory -- for temp files.
The last three, while in the simulator are in the project's Sandbox master folder. On device who knows where the folders really are.
In your case, if your JSON file is going to be included in with your downloadble app, your .json file should be in the same folder with your main.lua (or a sub folder) and referenced in system.ResourceDirectory.