summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-01-22 11:33:17 +0100
committerVolker Lendecke <vl@samba.org>2008-01-22 12:39:47 +0100
commit559603ad693ede382c566cb8bbd8e6bd8d5750a6 (patch)
tree7762739ed51074ced10ab3d2d1c3f5814613a64e /source3
parenta4c2b04a2b46fd308e98cc83c26de8307f5196a5 (diff)
downloadsamba-559603ad693ede382c566cb8bbd8e6bd8d5750a6.tar.gz
samba-559603ad693ede382c566cb8bbd8e6bd8d5750a6.tar.bz2
samba-559603ad693ede382c566cb8bbd8e6bd8d5750a6.zip
Get Samba version or capability information from Windows
On Jan 21 16:18, Danilo Almeida wrote: > Corina wrote: > > > + time_t samba_gitcommitdate; > > And: > > > + SIVAL(pdata,28,extended_info.samba_gitcommitdate); > > + memcpy(pdata+32,extended_info.samba_version_string,32); > > Note that you are dropping bits on a system w/64-bit time_t, and that this has the 2038 problem. Right. I changed samba_gitcommitdate from time_t to NTTIME and shortened samba_version_string to 28 bytes. New patch below. Thanks, Corinna (This used to be commit 28aa1c199d3a22cda34afcaab49c0561eeb0abcb)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/smb.h12
-rw-r--r--source3/lib/version.c29
-rw-r--r--source3/smbd/trans2.c7
3 files changed, 48 insertions, 0 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 7de3568701..c859200462 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1936,4 +1936,16 @@ enum usershare_err {
/* Different reasons for closing a file. */
enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
+/* Used in SMB_FS_OBJECTID_INFORMATION requests. Must be exactly 48 bytes. */
+#define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
+#define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
+struct smb_extended_info {
+ uint32 samba_magic; /* Always SAMBA_EXTRA_INFO_MAGIC */
+ uint32 samba_version; /* Major/Minor/Release/Revision */
+ uint32 samba_subversion; /* Prerelease/RC/Vendor patch */
+ NTTIME samba_gitcommitdate;
+ char samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
+};
+extern void samba_extended_info_version(struct smb_extended_info *);
+
#endif /* _SMB_H */
diff --git a/source3/lib/version.c b/source3/lib/version.c
index 3cae02ad2e..38c4f45ac6 100644
--- a/source3/lib/version.c
+++ b/source3/lib/version.c
@@ -59,3 +59,32 @@ const char *samba_version_string(void)
return samba_version;
#endif
}
+
+void samba_extended_info_version(struct smb_extended_info *extended_info)
+{
+ assert(extended_info != NULL);
+
+ extended_info->samba_magic = SAMBA_EXTENDED_INFO_MAGIC;
+ extended_info->samba_version = ((SAMBA_VERSION_MAJOR & 0xff) << 24)
+ | ((SAMBA_VERSION_MINOR & 0xff) << 16)
+ | ((SAMBA_VERSION_RELEASE & 0xff) << 8);
+#ifdef SAMBA_VERSION_REVISION
+ extended_info->samba_version |= (tolower(*SAMBA_VERSION_REVISION) - 'a' + 1) & 0xff;
+#endif
+#ifdef SAMBA_VERSION_RC_RELEASE
+ extended_info->samba_subversion |= (SAMBA_VERSION_RC_RELEASE & 0xff) << 24;
+#else
+#ifdef SAMBA_VERSION_PRE_RELEASE
+ extended_info->samba_subversion |= (SAMBA_VERSION_PRE_RELEASE & 0xff) << 16;
+#endif
+#endif
+#ifdef SAMBA_VERSION_VENDOR_PATCH
+ extended_info->samba_subversion |= (SAMBA_VERSION_VENDOR_PATCH & 0xffff);
+#endif
+ /* FIXME: samba_gitcommitdate should contain the git commit date. */
+ unix_to_nt_time(&extended_info->samba_gitcommitdate, time(NULL));
+
+ snprintf (extended_info->samba_version_string,
+ SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH,
+ "%s", samba_version_string());
+}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index b5b3ea751b..1243bdd9d2 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2797,7 +2797,14 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
case SMB_FS_OBJECTID_INFORMATION:
{
unsigned char objid[16];
+ struct smb_extended_info extended_info;
memcpy(pdata,create_volume_objectid(conn, objid),16);
+ samba_extended_info_version (&extended_info);
+ SIVAL(pdata,16,extended_info.samba_magic);
+ SIVAL(pdata,20,extended_info.samba_version);
+ SIVAL(pdata,24,extended_info.samba_subversion);
+ SBIG_UINT(pdata,28,extended_info.samba_gitcommitdate);
+ memcpy(pdata+36,extended_info.samba_version_string,28);
data_len = 64;
break;
}