Colin Dean
2015-04-27 19:09:10 UTC
Hello,
Iâm encountering an unexpected exception while retrieving SIDs/ACLs for a
file served by Windows Server 2012 Standard Edition. Weâre running on
Windows in this instance, if that matters.
Caused by: java.io.IOException: Unexpected fragment length: 28757
          at jcifs.dcerpc.DcerpcPipeHandle.doReceiveFragment
(DcerpcPipeHandle.java:96)
          at jcifs.dcerpc.DcerpcHandle.sendrecv(DcerpcHandle.java:220)
at jcifs.smb.SID.resolveSids(SID.java:94)
          at com.vivisimo.connector.smb.SMBConnector.resolveSids
(SMBConnector.java:629) ... 10 more
This is approximately where our code hands off to jcifs to resolve the
SIDs:
SID[] sidsToResolveArray = sidsToResolve.toArray(new SID[0]);
try {
LsaPolicyHandle policyHandle = null;
try {
policyHandle = handle.openPolicyHandle(file);
SID.resolveSids(handle.getHandle(), policyHandle,
sidsToResolveArray);
} finally {
if (policyHandle != null) {
LOGGER.debug("Closing Policy handle for [" + file +
"]");
policyHandle.close();
}
policyHandle = null;
}
} catch (IOException e) {
throw new ConnectorException(e);
}
It dies shortly after we call SID.resolveSids() there in the middle of the
inner try.
We have a few theories:
1. This filesystem has a lot of files with Japanese characters in the
filename. We considered that perhaps jCIFS or our software using it lacks
support for Japanese characters, but we set up a testing environment with a
bunch of files with Japanese filenames and it works for us. Weâre pretty
certain that our configuration mirrors that of the erring environment, but
there might be subtle differences were are not able to replicate (e.g. real
data instead of made up test data).
2. All of the files that are failing (weâre crawling a filesystem) share
one trait: they have what appears in the Windows properties a permitted
user that shows as âunknown userâ, which may be an artifact remaining after
the user was removed but its explicit permissions remained. Processing on a
directory that has no âunknown usersâ yields no failures.
This leads me to believe that jCIFS is failing on unknown users. However,
looking through the source, I donât see an obvious way to detect this.
The obvious workaround appears to be âclean your unknown usersâ but I think
this could be detectable and loggable during our processing of the share.
Iâd appreciate input on this.
Colin Dean
Advisory Software Engineer &
Tech Lead, Watson Explorer
Connectivity
email: ***@us.ibm.com |
tel: +1 (412) 315-2066
Find me on: LinkedIn:
http://linkedin.com/in/colindean
Github:
http://github.com/colindean
Launchpad:
http://launchpad.net/~colindean
IBM Watson Group Watson on Facebook: http://www.facebook.com/ibmwatson
Watson on Twitter: https://twitter.com/@ibmwatson
Watson on YouTube:
http://www.youtube.com/user/IBMWatsonSolutions/videos
Iâm encountering an unexpected exception while retrieving SIDs/ACLs for a
file served by Windows Server 2012 Standard Edition. Weâre running on
Windows in this instance, if that matters.
Caused by: java.io.IOException: Unexpected fragment length: 28757
          at jcifs.dcerpc.DcerpcPipeHandle.doReceiveFragment
(DcerpcPipeHandle.java:96)
          at jcifs.dcerpc.DcerpcHandle.sendrecv(DcerpcHandle.java:220)
at jcifs.smb.SID.resolveSids(SID.java:94)
          at com.vivisimo.connector.smb.SMBConnector.resolveSids
(SMBConnector.java:629) ... 10 more
This is approximately where our code hands off to jcifs to resolve the
SIDs:
SID[] sidsToResolveArray = sidsToResolve.toArray(new SID[0]);
try {
LsaPolicyHandle policyHandle = null;
try {
policyHandle = handle.openPolicyHandle(file);
SID.resolveSids(handle.getHandle(), policyHandle,
sidsToResolveArray);
} finally {
if (policyHandle != null) {
LOGGER.debug("Closing Policy handle for [" + file +
"]");
policyHandle.close();
}
policyHandle = null;
}
} catch (IOException e) {
throw new ConnectorException(e);
}
It dies shortly after we call SID.resolveSids() there in the middle of the
inner try.
We have a few theories:
1. This filesystem has a lot of files with Japanese characters in the
filename. We considered that perhaps jCIFS or our software using it lacks
support for Japanese characters, but we set up a testing environment with a
bunch of files with Japanese filenames and it works for us. Weâre pretty
certain that our configuration mirrors that of the erring environment, but
there might be subtle differences were are not able to replicate (e.g. real
data instead of made up test data).
2. All of the files that are failing (weâre crawling a filesystem) share
one trait: they have what appears in the Windows properties a permitted
user that shows as âunknown userâ, which may be an artifact remaining after
the user was removed but its explicit permissions remained. Processing on a
directory that has no âunknown usersâ yields no failures.
This leads me to believe that jCIFS is failing on unknown users. However,
looking through the source, I donât see an obvious way to detect this.
The obvious workaround appears to be âclean your unknown usersâ but I think
this could be detectable and loggable during our processing of the share.
Iâd appreciate input on this.
Colin Dean
Advisory Software Engineer &
Tech Lead, Watson Explorer
Connectivity
email: ***@us.ibm.com |
tel: +1 (412) 315-2066
Find me on: LinkedIn:
http://linkedin.com/in/colindean
Github:
http://github.com/colindean
Launchpad:
http://launchpad.net/~colindean
IBM Watson Group Watson on Facebook: http://www.facebook.com/ibmwatson
Watson on Twitter: https://twitter.com/@ibmwatson
Watson on YouTube:
http://www.youtube.com/user/IBMWatsonSolutions/videos