cifs interview questions
Top cifs frequently asked interview questions
I have a windows share mounted via CIFS on an ubuntu server. I need to a way to know when a new file has been added to the Windows share. I tried this inotify program:
http://www.thegeekstuff.com/2010/04/inotify-c-program-example/
Which works fine with standard directories, but is unable to catch any CIFS changes. I don't neccessarily need to use inotify, although I would like to, but any suggestions on how to accomplish getting file create notifications would be great.
Source: (StackOverflow)
I check iOS document and also google it for a while and get the impression that iOS does not support samba (although there is a samba app for jailbreak iPhone).
But then how do the app FileBrowser achieves that? Does that mean they implemented samba support by their own ?
I also find there is an open source library called tango that provides limited support for samba. So my question is that the best samba support I can get ?
Source: (StackOverflow)
I wanted to ask about testing suites available for testing Linux file systems. I am looking for more of stress and load testing suites, which can stress the system, find corruptions by validating the data it wrote, among other things.
Is there such a tool available for both local FS like ext*, and network protocols such as NFS/CIFS?
Thanks in advance.
Source: (StackOverflow)
Will data traffic go through the host application program or will be dealt remotely in scenarios where C#'s File.Copy is used:
File.Copy(@"\\SERVER13\LOL\ROFL.txt", @"\\SERVER13\ROFL.txt")
Cheers n thx!
Source: (StackOverflow)
I just installed Ubuntu 12.10 and I was trying to mount a folder to the Ubuntu system.
So I used:
sudo smbmount <folder> /path/to/my/folder -ouser=<my id>, dom=<my dom>
but the smbmount was not found...
All I have now is cifs-utils.
The command above works in Ubuntu 12.04, but not 12.10.
Any hints?
Thx in advance :)
Source: (StackOverflow)
I am writing a streaming server for linux that reads files from CIFS mounts and sends
them over a socket. Ideally, linux will cache the file in memory so that subsequent
reads will be faster. Is this the case? Can I tell the kernel to cache
network reads ?
Edit: there will be multiple reads, but no writes, on these files.
Thanks!
Update: I've tested this on a CIFS volume, using fadvise POSIX_FADV_WILLNEED to cache the file locally (using linux-ftools on command line). Turns out that the volume needs to be mounted in read-write mode for this to work. In read only mode, the fadvise seems to be ignored. This must have something to do with the samba oplock mechanism.
Source: (StackOverflow)
I'm trying an SMB/CIFS Java implementation from Alfresco, named Alfresco JLan.
My server has stand up correctly, but I'm using non-privileged ports for SMB (1445, 1139, 1138, 1137).
I've used that shell code:
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe iptable_nat
iptables -F
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 445 -j REDIRECT --to-ports 1445
iptables -t nat -A PREROUTING -p tcp --dport 139 -j REDIRECT --to-ports 1139
iptables -t nat -A PREROUTING -p udp --dport 137 -j REDIRECT --to-ports 1137
iptables -t nat -A PREROUTING -p udp --dport 138 -j REDIRECT --to-ports 1138
If I try:
telnet localhost 1445
everything goes OK.
But, when I try with:
telnet localhost 445
I receive:
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Does anyone know what is wrong? I'm using Ubuntu 12.04.
Source: (StackOverflow)
I have a raspberry pi that I am trying to mount a remote samba share on, but I get permission denied. On another mounting the same share with th same command works.
Raspberry pi:
root@xbian:~# mount -t cifs //192.168.249.72/root /media/SS -o username=root,password=654321
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
root@xbian:~# uname -a
Linux xbian 3.9.8+ #2 PREEMPT Tue Jul 2 17:38:12 CEST 2013 armv6l GNU/Linux
Ubuntu:
root@dakLinux:~# mount -t cifs //192.168.249.72/root /media/SS -o username=root,password=654321
root@dakLinux:~# uname -a
Linux dakLinux 2.6.31-17-generic #54-Ubuntu SMP Thu Dec 10 16:20:31 UTC 2009 i686 i686 i686 GNU/Linux
Is this a kernel issue or a linux version issue? Is there a way to make this work?
Source: (StackOverflow)
I am trying to add a set of attributes at creation time as in the following example.
This code creates a new file on a POSIX file system with specific permissions ("rw-rw-r--") in mounted CIFS share.
public static void main(String[] args) {
Path new_path = Paths.get("/mnt/test/new_file.txt");
System.out.println(new_path.getFileSystem().supportedFileAttributeViews().contains("posix"));
Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rw-rw-r--");
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
try {
Files.createFile(new_path, attr);
} catch (IOException e) {
System.err.println(e);
}
}
After run the simple code, the file was created but the permissions for it looks
rwxrwSrwx 1 root root 0 May 5 2014 new_file.txt
instead of what I needed (look in the code 'rw-rw-r--')
Can someone help me with that issue?
Source: (StackOverflow)
I got a fresh installation of Alfresco 4.2 on Ubuntu 12.04. I had "successfully" configured CIFS and modified iptables to include (NAT) ports(1445 TCP -- 445 TCP and 1137-1139 TCP/UDP to 137-139 TCP/UDP) for SMB and NetBios. Also the machine is an EC2 instance at amazon so i've created the Security group to include inbound traffic 445,137-139 TCP and 137-139 UDP. When connecting from a windows machine using network drive, I successfully connect (seems port 445 is working) but just show two folders (one is site-name and the other swsdp). When i moved to the site folder there is no content (\server\alfresco\site-name), so is missing the documentLibrary and all subfolders.
I've double checked that the User used to connect had permissions to see the content (even connect as Administrator and still the problem). Also i have set debug for CIFS under Alfresco's log4j with non-error or anything under the application log.
I followed steps advised on http://andoylang.wordpress.com/2010/07/20/alfresco-with-cifs/ and try to isolate the problem within the linux box. When i used sbmclient to connect i got the following error:
bitnami@ip-10-46-57-42:/opt/bitnami/apache-tomcat/shared/classes$ smbclient -U user \\\\localhost\\drive -p 1139
Enter user's password:xxxxx
read_fd_with_timeout failed, read error = NT_STATUS_IO_TIMEOUT.
Receiving SMB: Server 127.0.0.1 stopped responding
session request to LOCALHOST failed (Call timed out: server did not respond after 20000 milliseconds)
Domain=[WORKGROUP] OS=[Java] Server=[Alfresco CIFS Server 6.0.0]
tree connect failed: NT_STATUS_BAD_NETWORK_NAME`
So is my undestanding that the aunthentication service failed. I got the following debug entries at /opt/bitnami/apache-tomcat/webapps/alfresco/WEB-INF/classes/log4j.properties:
# CIFS server debugging
log4j.logger.org.alfresco.smb.protocol=debug
log4j.logger.org.alfresco.smb.protocol.auth=debug
But there not output associated to this Auth error on the log file. Is this the correct log4j file to enable this debug?
What else i can do for troubleshoot this?
Source: (StackOverflow)
Given a UNC path like \\server\share
, is there any way to determine, using the Win32 API, whether the local and remote computers are connecting using SMB or SMB2?
Source: (StackOverflow)
My application needs to securely mount an Isilon share using CIFS and Kerberos. My mount
attempt returns: Required key not available
:
mount -t cifs //fileserver.example.com/client123/files
/mnt/client123/files -o username=acoder,password=XXXXXX,sec=krb5
Response:
mount error(126): Required key not available
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Here are corresponding entries from /var/log/messages
Sep 16 16:33:49 clientbox kernel: CIFS VFS: Send error in SessSetup = -126
Sep 16 16:33:49 clientbox kernel: CIFS VFS: cifs_mount failed w/return code = -126
Background & Config
I added a keytab using:
/usr/bin/ktutil
addent -password -p acoder@EXAMPLE.COM -k 1 -e rc4-hmac
addent -password -p acoder@EXAMPLE.COM -k 1 -e aes256-cts
wkt /etc/krb5.keytab
Checked with klist -kte
:
[acoder@clientbox]# klist -kte
Keytab name: FILE:/etc/krb5.keytab
KVNO Timestamp Principal
---- ----------------- --------------------------------------------------------
1 09/16/15 16:24:32 acoder@EXAMPLE.COM (arcfour-hmac)
1 09/16/15 16:25:46 acoder@EXAMPLE.COM (aes256-cts-hmac-sha1-96)
Here's request-key.conf
:
#OP TYPE DESCRIPTION CALLOUT INFO PROGRAM ARG1 ARG2 ARG3 ...
#====== ======= =============== =============== ===============================
create user debug:* negate /bin/keyctl negate %k 30 %S
create user debug:loop:* * |/bin/cat
create user debug:* * /usr/share/keyutils/request-key-debug.sh %k %d %c %S
negate * * * /bin/keyctl negate %k 30 %S
create cifs.spnego * * /usr/sbin/cifs.upcall %k
create dns_resolver * * /usr/sbin/cifs.upcall %k
Ticket cache:
# klist | grep "Ticket cache:"
Ticket cache: FILE:/tmp/krb5cc_0
What could be causing the "Required key not available" error?
EDIT:
I enabled debugging in CIFS, and attempted to mount the share again. Here's that output:
fs/cifs/cifsfs.c: Devname: //fileserver.example.com/client123/files flags: 0
fs/cifs/connect.c: prefix path /files
fs/cifs/connect.c: Username: acoder
fs/cifs/connect.c: file mode: 0x1ed dir mode: 0x1ed
fs/cifs/connect.c: CIFS VFS: in cifs_mount as Xid: 8 with uid: 0
fs/cifs/connect.c: UNC: \\fileserver.example.com/client123/files ip: 1.2.3.4
fs/cifs/connect.c: Socket created
fs/cifs/connect.c: sndbuf 19800 rcvbuf 87380 rcvtimeo 0x1b58
fs/cifs/connect.c: CIFS VFS: in cifs_get_smb_ses as Xid: 9 with uid: 0
fs/cifs/connect.c: Demultiplex PID: 22937
fs/cifs/connect.c: Existing smb sess not found
fs/cifs/cifssmb.c: secFlags 0x9
fs/cifs/cifssmb.c: Kerberos only mechanism, enable extended security
fs/cifs/transport.c: For smb_command 114
fs/cifs/transport.c: Sending smb: smb_len=78
fs/cifs/connect.c: RFC1002 header 0xbc
fs/cifs/transport.c: cifs_sync_mid_result: cmd=114 mid=1 state=4
fs/cifs/cifssmb.c: Dialect: 2
fs/cifs/asn1.c: OID len = 7 oid = 0x1 0x2 0x348 0x1bb92
fs/cifs/asn1.c: OID len = 6 oid = 0x1 0x3 0x5 0x1
fs/cifs/asn1.c: OID len = 7 oid = 0x1 0x2 0x348 0xbb92
fs/cifs/asn1.c: OID len = 10 oid = 0x1 0x3 0x6 0x1
fs/cifs/asn1.c: Need to call asn1_octets_decode() function for not_defined_in_RFC4178@please_ignore
fs/cifs/cifssmb.c: negprot rc 0
fs/cifs/connect.c: Security Mode: 0x3 Capabilities: 0x8000e2fc TimeAdjust: 0
fs/cifs/sess.c: sess setup type 4
fs/cifs/cifs_spnego.c: key description = ver=0x2;host=fileserver.example.com;ip4=1.2.3.4;sec=krb5;uid=0x0;creduid=0x0;user=acoder;pid=0xXXXXX
fs/cifs/sess.c: ssetup freeing small buf ffff8804359b02701
CIFS VFS: Send error in SessSetup = -126
fs/cifs/connect.c: CIFS VFS: leaving cifs_get_smb_ses (xid = 9) rc = -126
fs/cifs/connect.c: CIFS VFS: leaving cifs_mount (xid = 8) rc = -126
CIFS VFS: cifs_mount failed w/return code = -126
Source: (StackOverflow)
I have a weird problem where PHP's file_put_contents()
and fwrite()
(after opening file handle with fopen('filename', 'w');
) functions are not truncating the target file as stated by the PHP docs for fwrite()
. The file resides on a Seagate BlackArmor NAS device, which is mounted on a Linux server (Ubuntu 10.04) using CIFS, as follows:
mount -t cifs -o defaults,credentials=/etc/smbpass/demo.smbpass,uid=1005,gid=1005,dir_mode=0770,file_mod=0660 //xxx.xxx.xxx.xxx/demo/files /var/www/mysite/src/files/
Example:
Contents of myfile.txt: thisisabigfatpandaonwheelsgoingdownthestreet
Run PHP script with code: file_put_contents('myfile.txt', 'blah');
Contents of myfile.txt: blahisabigfatpandaonwheelsgoingdownthestreet
The expected contents of the file is obviously blah
, but that's not the case.
Any ideas?
Source: (StackOverflow)
have developed an application to run on a target with 2.6.10 kernel. A shared folder on a windows machine is mounted via command:
mount -t cifs -o username=xxx,password=xxx,forcedirectio //192.168.170.67/57 /fsRecord
As you can understand from the command option forcedirectio
, I want to disable caching on the client side. But I can't.
The amount of free RAM on target is 40 MB. When I copy a file sized about 10MB, free RAM size decreases to 30 MB.
The kernel 2.6.10 uses cifs.1.28. I also set oplockEnabled as 0 (in both source code and /proc/fs/cifs/OplockEnabled). But it did not stop caching. How can I disable caching on cifs client for real?
Source: (StackOverflow)
I'm modifying files on a UNIX system and accessing them on a Windows box. The server runs samba and there is some amount of caching done by the client. When I modify the file on the UNIX side, the only reliable way to see the new version of the file is to right click in Windows Explorer and select "refresh".
I'm looking for the Windows API equivalent of right-clicking in Windows Explorer and selecting "refresh". There are other questions on SO about sending a message to Explorer to cause it to refresh, but that's not what I want: I don't care about the contents of the Explorer window and I would prefer to not even need one open to the target directory. I just want to integrate the cache-defeating effect into my program so I avoid seeing stale data.
Source: (StackOverflow)